<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
<title>Coverage for c:\program files\python26\lib\logging\__init__</title>
<link rel='stylesheet' href='style.css' type='text/css'>
<script type='text/javascript' src='jquery-1.3.2.min.js'></script>
<script type='text/javascript'>
function toggle_lines(btn, cls) {
    var btn = $(btn);
    var hide = "hide_"+cls;
    if (btn.hasClass(hide)) {
        $("#source ."+cls).removeClass(hide);
        btn.removeClass(hide);
    }
    else {
        $("#source ."+cls).addClass(hide);
        btn.addClass(hide);
    }
}
</script>
</head>
<body>
<div id='header'>
    <div class='content'>
        <h1>Coverage for <b>c:\program files\python26\lib\logging\__init__</b> :
            <span class='pc_cov'>29%</span>
        </h1>
        <h2 class='stats'>
            576 statements
            <span class='run hide_run' onclick='toggle_lines(this, "run")'>210 run</span>
            <span class='exc' onclick='toggle_lines(this, "exc")'>0 excluded</span>
            <span class='mis' onclick='toggle_lines(this, "mis")'>366 missing</span>
            
                <span class='par run hide_run' onclick='toggle_lines(this, "par")'>11 partial</span>
            
        </h2>
    </div>
</div>

<div id='source'>
<table cellspacing='0' cellpadding='0'>
<tr>
<td class='linenos' valign='top'>
<p class='pln'>1</p>
<p class='pln'>2</p>
<p class='pln'>3</p>
<p class='pln'>4</p>
<p class='pln'>5</p>
<p class='pln'>6</p>
<p class='pln'>7</p>
<p class='pln'>8</p>
<p class='pln'>9</p>
<p class='pln'>10</p>
<p class='pln'>11</p>
<p class='pln'>12</p>
<p class='pln'>13</p>
<p class='pln'>14</p>
<p class='pln'>15</p>
<p class='pln'>16</p>
<p class='stm run hide_run'>17</p>
<p class='pln'>18</p>
<p class='pln'>19</p>
<p class='pln'>20</p>
<p class='pln'>21</p>
<p class='pln'>22</p>
<p class='pln'>23</p>
<p class='pln'>24</p>
<p class='pln'>25</p>
<p class='stm run hide_run'>26</p>
<p class='pln'>27</p>
<p class='pln'>28</p>
<p class='pln'>29</p>
<p class='pln'>30</p>
<p class='stm run hide_run'>31</p>
<p class='pln'>32</p>
<p class='stm run hide_run'>33</p>
<p class='stm run hide_run'>34</p>
<p class='stm mis'>35</p>
<p class='stm mis'>36</p>
<p class='pln'>37</p>
<p class='stm run hide_run'>38</p>
<p class='stm run hide_run'>39</p>
<p class='stm run hide_run'>40</p>
<p class='stm mis'>41</p>
<p class='stm mis'>42</p>
<p class='pln'>43</p>
<p class='stm run hide_run'>44</p>
<p class='stm run hide_run'>45</p>
<p class='stm run hide_run'>46</p>
<p class='stm run hide_run'>47</p>
<p class='pln'>48</p>
<p class='pln'>49</p>
<p class='pln'>50</p>
<p class='pln'>51</p>
<p class='pln'>52</p>
<p class='pln'>53</p>
<p class='pln'>54</p>
<p class='pln'>55</p>
<p class='pln'>56</p>
<p class='stm par run hide_run'>57</p>
<p class='stm mis'>58</p>
<p class='stm par run hide_run'>59</p>
<p class='stm run hide_run'>60</p>
<p class='pln'>61</p>
<p class='stm mis'>62</p>
<p class='stm run hide_run'>63</p>
<p class='pln'>64</p>
<p class='pln'>65</p>
<p class='stm run hide_run'>66</p>
<p class='pln'>67</p>
<p class='stm mis'>68</p>
<p class='stm mis'>69</p>
<p class='stm mis'>70</p>
<p class='stm mis'>71</p>
<p class='pln'>72</p>
<p class='stm par run hide_run'>73</p>
<p class='pln'>74</p>
<p class='pln'>75</p>
<p class='pln'>76</p>
<p class='pln'>77</p>
<p class='pln'>78</p>
<p class='pln'>79</p>
<p class='pln'>80</p>
<p class='pln'>81</p>
<p class='pln'>82</p>
<p class='pln'>83</p>
<p class='pln'>84</p>
<p class='pln'>85</p>
<p class='stm run hide_run'>86</p>
<p class='pln'>87</p>
<p class='pln'>88</p>
<p class='pln'>89</p>
<p class='pln'>90</p>
<p class='pln'>91</p>
<p class='stm run hide_run'>92</p>
<p class='pln'>93</p>
<p class='pln'>94</p>
<p class='pln'>95</p>
<p class='pln'>96</p>
<p class='stm run hide_run'>97</p>
<p class='pln'>98</p>
<p class='pln'>99</p>
<p class='pln'>100</p>
<p class='pln'>101</p>
<p class='stm run hide_run'>102</p>
<p class='pln'>103</p>
<p class='pln'>104</p>
<p class='pln'>105</p>
<p class='pln'>106</p>
<p class='stm run hide_run'>107</p>
<p class='pln'>108</p>
<p class='pln'>109</p>
<p class='pln'>110</p>
<p class='pln'>111</p>
<p class='pln'>112</p>
<p class='pln'>113</p>
<p class='pln'>114</p>
<p class='pln'>115</p>
<p class='pln'>116</p>
<p class='pln'>117</p>
<p class='pln'>118</p>
<p class='pln'>119</p>
<p class='stm run hide_run'>120</p>
<p class='stm run hide_run'>121</p>
<p class='stm run hide_run'>122</p>
<p class='stm run hide_run'>123</p>
<p class='stm run hide_run'>124</p>
<p class='stm run hide_run'>125</p>
<p class='stm run hide_run'>126</p>
<p class='stm run hide_run'>127</p>
<p class='pln'>128</p>
<p class='stm run hide_run'>129</p>
<p class='pln'>130</p>
<p class='pln'>131</p>
<p class='pln'>132</p>
<p class='pln'>133</p>
<p class='pln'>134</p>
<p class='pln'>135</p>
<p class='pln'>136</p>
<p class='pln'>137</p>
<p class='pln'>138</p>
<p class='pln'>139</p>
<p class='pln'>140</p>
<p class='pln'>141</p>
<p class='pln'>142</p>
<p class='pln'>143</p>
<p class='pln'>144</p>
<p class='stm run hide_run'>145</p>
<p class='pln'>146</p>
<p class='pln'>147</p>
<p class='pln'>148</p>
<p class='pln'>149</p>
<p class='pln'>150</p>
<p class='pln'>151</p>
<p class='pln'>152</p>
<p class='pln'>153</p>
<p class='pln'>154</p>
<p class='pln'>155</p>
<p class='pln'>156</p>
<p class='pln'>157</p>
<p class='pln'>158</p>
<p class='stm mis'>159</p>
<p class='pln'>160</p>
<p class='stm run hide_run'>161</p>
<p class='pln'>162</p>
<p class='pln'>163</p>
<p class='pln'>164</p>
<p class='pln'>165</p>
<p class='pln'>166</p>
<p class='stm mis'>167</p>
<p class='stm mis'>168</p>
<p class='stm mis'>169</p>
<p class='stm mis'>170</p>
<p class='pln'>171</p>
<p class='stm mis'>172</p>
<p class='pln'>173</p>
<p class='pln'>174</p>
<p class='pln'>175</p>
<p class='pln'>176</p>
<p class='pln'>177</p>
<p class='pln'>178</p>
<p class='pln'>179</p>
<p class='pln'>180</p>
<p class='pln'>181</p>
<p class='pln'>182</p>
<p class='pln'>183</p>
<p class='pln'>184</p>
<p class='pln'>185</p>
<p class='stm run hide_run'>186</p>
<p class='pln'>187</p>
<p class='stm run hide_run'>188</p>
<p class='pln'>189</p>
<p class='pln'>190</p>
<p class='pln'>191</p>
<p class='pln'>192</p>
<p class='pln'>193</p>
<p class='pln'>194</p>
<p class='stm run hide_run'>195</p>
<p class='stm run hide_run'>196</p>
<p class='stm par run hide_run'>197</p>
<p class='stm run hide_run'>198</p>
<p class='pln'>199</p>
<p class='stm run hide_run'>200</p>
<p class='pln'>201</p>
<p class='pln'>202</p>
<p class='pln'>203</p>
<p class='stm par run hide_run'>204</p>
<p class='stm run hide_run'>205</p>
<p class='pln'>206</p>
<p class='pln'>207</p>
<p class='pln'>208</p>
<p class='pln'>209</p>
<p class='pln'>210</p>
<p class='stm run hide_run'>211</p>
<p class='pln'>212</p>
<p class='pln'>213</p>
<p class='pln'>214</p>
<p class='pln'>215</p>
<p class='pln'>216</p>
<p class='pln'>217</p>
<p class='pln'>218</p>
<p class='pln'>219</p>
<p class='pln'>220</p>
<p class='pln'>221</p>
<p class='pln'>222</p>
<p class='stm run hide_run'>223</p>
<p class='pln'>224</p>
<p class='pln'>225</p>
<p class='pln'>226</p>
<p class='pln'>227</p>
<p class='stm mis'>228</p>
<p class='stm mis'>229</p>
<p class='stm mis'>230</p>
<p class='pln'>231</p>
<p class='pln'>232</p>
<p class='pln'>233</p>
<p class='pln'>234</p>
<p class='pln'>235</p>
<p class='pln'>236</p>
<p class='pln'>237</p>
<p class='pln'>238</p>
<p class='pln'>239</p>
<p class='pln'>240</p>
<p class='pln'>241</p>
<p class='pln'>242</p>
<p class='pln'>243</p>
<p class='stm mis'>244</p>
<p class='pln'>245</p>
<p class='pln'>246</p>
<p class='stm mis'>247</p>
<p class='stm mis'>248</p>
<p class='stm mis'>249</p>
<p class='stm mis'>250</p>
<p class='stm mis'>251</p>
<p class='stm mis'>252</p>
<p class='stm mis'>253</p>
<p class='stm mis'>254</p>
<p class='stm mis'>255</p>
<p class='stm mis'>256</p>
<p class='stm mis'>257</p>
<p class='stm mis'>258</p>
<p class='stm mis'>259</p>
<p class='stm mis'>260</p>
<p class='stm mis'>261</p>
<p class='stm mis'>262</p>
<p class='stm mis'>263</p>
<p class='stm mis'>264</p>
<p class='stm mis'>265</p>
<p class='stm mis'>266</p>
<p class='stm mis'>267</p>
<p class='pln'>268</p>
<p class='stm mis'>269</p>
<p class='stm mis'>270</p>
<p class='stm mis'>271</p>
<p class='stm mis'>272</p>
<p class='stm mis'>273</p>
<p class='pln'>274</p>
<p class='stm mis'>275</p>
<p class='stm mis'>276</p>
<p class='stm mis'>277</p>
<p class='pln'>278</p>
<p class='stm mis'>279</p>
<p class='pln'>280</p>
<p class='stm run hide_run'>281</p>
<p class='stm mis'>282</p>
<p class='pln'>283</p>
<p class='pln'>284</p>
<p class='stm run hide_run'>285</p>
<p class='pln'>286</p>
<p class='pln'>287</p>
<p class='pln'>288</p>
<p class='pln'>289</p>
<p class='pln'>290</p>
<p class='pln'>291</p>
<p class='stm mis'>292</p>
<p class='stm mis'>293</p>
<p class='pln'>294</p>
<p class='stm mis'>295</p>
<p class='stm mis'>296</p>
<p class='stm mis'>297</p>
<p class='stm mis'>298</p>
<p class='stm mis'>299</p>
<p class='stm mis'>300</p>
<p class='stm mis'>301</p>
<p class='stm mis'>302</p>
<p class='stm mis'>303</p>
<p class='pln'>304</p>
<p class='stm run hide_run'>305</p>
<p class='pln'>306</p>
<p class='pln'>307</p>
<p class='pln'>308</p>
<p class='pln'>309</p>
<p class='pln'>310</p>
<p class='pln'>311</p>
<p class='stm mis'>312</p>
<p class='stm mis'>313</p>
<p class='stm mis'>314</p>
<p class='pln'>315</p>
<p class='pln'>316</p>
<p class='pln'>317</p>
<p class='pln'>318</p>
<p class='pln'>319</p>
<p class='stm run hide_run'>320</p>
<p class='pln'>321</p>
<p class='pln'>322</p>
<p class='pln'>323</p>
<p class='pln'>324</p>
<p class='pln'>325</p>
<p class='pln'>326</p>
<p class='pln'>327</p>
<p class='pln'>328</p>
<p class='pln'>329</p>
<p class='pln'>330</p>
<p class='pln'>331</p>
<p class='pln'>332</p>
<p class='pln'>333</p>
<p class='pln'>334</p>
<p class='pln'>335</p>
<p class='pln'>336</p>
<p class='pln'>337</p>
<p class='pln'>338</p>
<p class='pln'>339</p>
<p class='pln'>340</p>
<p class='pln'>341</p>
<p class='pln'>342</p>
<p class='pln'>343</p>
<p class='pln'>344</p>
<p class='pln'>345</p>
<p class='pln'>346</p>
<p class='pln'>347</p>
<p class='pln'>348</p>
<p class='pln'>349</p>
<p class='pln'>350</p>
<p class='pln'>351</p>
<p class='pln'>352</p>
<p class='pln'>353</p>
<p class='pln'>354</p>
<p class='pln'>355</p>
<p class='pln'>356</p>
<p class='pln'>357</p>
<p class='pln'>358</p>
<p class='pln'>359</p>
<p class='pln'>360</p>
<p class='pln'>361</p>
<p class='stm run hide_run'>362</p>
<p class='pln'>363</p>
<p class='stm run hide_run'>364</p>
<p class='pln'>365</p>
<p class='pln'>366</p>
<p class='pln'>367</p>
<p class='pln'>368</p>
<p class='pln'>369</p>
<p class='pln'>370</p>
<p class='pln'>371</p>
<p class='stm run hide_run'>372</p>
<p class='stm run hide_run'>373</p>
<p class='pln'>374</p>
<p class='stm run hide_run'>375</p>
<p class='stm run hide_run'>376</p>
<p class='pln'>377</p>
<p class='stm run hide_run'>378</p>
<p class='pln'>379</p>
<p class='pln'>380</p>
<p class='pln'>381</p>
<p class='pln'>382</p>
<p class='pln'>383</p>
<p class='pln'>384</p>
<p class='pln'>385</p>
<p class='pln'>386</p>
<p class='pln'>387</p>
<p class='pln'>388</p>
<p class='pln'>389</p>
<p class='pln'>390</p>
<p class='pln'>391</p>
<p class='pln'>392</p>
<p class='pln'>393</p>
<p class='pln'>394</p>
<p class='pln'>395</p>
<p class='stm mis'>396</p>
<p class='stm mis'>397</p>
<p class='stm mis'>398</p>
<p class='pln'>399</p>
<p class='stm mis'>400</p>
<p class='stm mis'>401</p>
<p class='stm mis'>402</p>
<p class='pln'>403</p>
<p class='stm run hide_run'>404</p>
<p class='pln'>405</p>
<p class='pln'>406</p>
<p class='pln'>407</p>
<p class='pln'>408</p>
<p class='pln'>409</p>
<p class='pln'>410</p>
<p class='stm mis'>411</p>
<p class='stm mis'>412</p>
<p class='stm mis'>413</p>
<p class='stm mis'>414</p>
<p class='stm mis'>415</p>
<p class='stm mis'>416</p>
<p class='stm mis'>417</p>
<p class='pln'>418</p>
<p class='stm run hide_run'>419</p>
<p class='pln'>420</p>
<p class='pln'>421</p>
<p class='pln'>422</p>
<p class='pln'>423</p>
<p class='pln'>424</p>
<p class='pln'>425</p>
<p class='pln'>426</p>
<p class='pln'>427</p>
<p class='pln'>428</p>
<p class='pln'>429</p>
<p class='pln'>430</p>
<p class='pln'>431</p>
<p class='stm mis'>432</p>
<p class='stm mis'>433</p>
<p class='stm mis'>434</p>
<p class='stm mis'>435</p>
<p class='stm mis'>436</p>
<p class='pln'>437</p>
<p class='pln'>438</p>
<p class='stm mis'>439</p>
<p class='stm mis'>440</p>
<p class='stm mis'>441</p>
<p class='stm mis'>442</p>
<p class='stm mis'>443</p>
<p class='stm mis'>444</p>
<p class='stm mis'>445</p>
<p class='pln'>446</p>
<p class='pln'>447</p>
<p class='pln'>448</p>
<p class='pln'>449</p>
<p class='stm run hide_run'>450</p>
<p class='pln'>451</p>
<p class='stm run hide_run'>452</p>
<p class='pln'>453</p>
<p class='pln'>454</p>
<p class='pln'>455</p>
<p class='stm run hide_run'>456</p>
<p class='pln'>457</p>
<p class='pln'>458</p>
<p class='pln'>459</p>
<p class='pln'>460</p>
<p class='stm mis'>461</p>
<p class='stm mis'>462</p>
<p class='pln'>463</p>
<p class='stm mis'>464</p>
<p class='pln'>465</p>
<p class='stm run hide_run'>466</p>
<p class='pln'>467</p>
<p class='pln'>468</p>
<p class='pln'>469</p>
<p class='stm mis'>470</p>
<p class='pln'>471</p>
<p class='stm run hide_run'>472</p>
<p class='pln'>473</p>
<p class='pln'>474</p>
<p class='pln'>475</p>
<p class='stm mis'>476</p>
<p class='pln'>477</p>
<p class='stm run hide_run'>478</p>
<p class='pln'>479</p>
<p class='pln'>480</p>
<p class='pln'>481</p>
<p class='stm mis'>482</p>
<p class='stm mis'>483</p>
<p class='stm mis'>484</p>
<p class='stm mis'>485</p>
<p class='stm mis'>486</p>
<p class='stm mis'>487</p>
<p class='stm mis'>488</p>
<p class='pln'>489</p>
<p class='pln'>490</p>
<p class='pln'>491</p>
<p class='pln'>492</p>
<p class='pln'>493</p>
<p class='stm run hide_run'>494</p>
<p class='pln'>495</p>
<p class='pln'>496</p>
<p class='pln'>497</p>
<p class='pln'>498</p>
<p class='pln'>499</p>
<p class='pln'>500</p>
<p class='pln'>501</p>
<p class='pln'>502</p>
<p class='pln'>503</p>
<p class='pln'>504</p>
<p class='stm run hide_run'>505</p>
<p class='pln'>506</p>
<p class='pln'>507</p>
<p class='pln'>508</p>
<p class='pln'>509</p>
<p class='pln'>510</p>
<p class='pln'>511</p>
<p class='pln'>512</p>
<p class='stm mis'>513</p>
<p class='stm mis'>514</p>
<p class='pln'>515</p>
<p class='stm run hide_run'>516</p>
<p class='pln'>517</p>
<p class='pln'>518</p>
<p class='pln'>519</p>
<p class='pln'>520</p>
<p class='pln'>521</p>
<p class='pln'>522</p>
<p class='stm mis'>523</p>
<p class='stm mis'>524</p>
<p class='stm mis'>525</p>
<p class='stm mis'>526</p>
<p class='stm mis'>527</p>
<p class='stm mis'>528</p>
<p class='stm mis'>529</p>
<p class='pln'>530</p>
<p class='stm run hide_run'>531</p>
<p class='pln'>532</p>
<p class='pln'>533</p>
<p class='pln'>534</p>
<p class='pln'>535</p>
<p class='stm run hide_run'>536</p>
<p class='pln'>537</p>
<p class='pln'>538</p>
<p class='pln'>539</p>
<p class='stm run hide_run'>540</p>
<p class='pln'>541</p>
<p class='stm run hide_run'>542</p>
<p class='pln'>543</p>
<p class='pln'>544</p>
<p class='pln'>545</p>
<p class='stm mis'>546</p>
<p class='stm mis'>547</p>
<p class='pln'>548</p>
<p class='stm run hide_run'>549</p>
<p class='pln'>550</p>
<p class='pln'>551</p>
<p class='pln'>552</p>
<p class='stm mis'>553</p>
<p class='stm mis'>554</p>
<p class='pln'>555</p>
<p class='stm run hide_run'>556</p>
<p class='pln'>557</p>
<p class='pln'>558</p>
<p class='pln'>559</p>
<p class='pln'>560</p>
<p class='pln'>561</p>
<p class='pln'>562</p>
<p class='pln'>563</p>
<p class='stm mis'>564</p>
<p class='stm mis'>565</p>
<p class='stm mis'>566</p>
<p class='stm mis'>567</p>
<p class='stm mis'>568</p>
<p class='stm mis'>569</p>
<p class='pln'>570</p>
<p class='pln'>571</p>
<p class='pln'>572</p>
<p class='pln'>573</p>
<p class='pln'>574</p>
<p class='stm run hide_run'>575</p>
<p class='stm run hide_run'>576</p>
<p class='pln'>577</p>
<p class='stm run hide_run'>578</p>
<p class='pln'>579</p>
<p class='pln'>580</p>
<p class='pln'>581</p>
<p class='pln'>582</p>
<p class='pln'>583</p>
<p class='pln'>584</p>
<p class='pln'>585</p>
<p class='pln'>586</p>
<p class='stm run hide_run'>587</p>
<p class='pln'>588</p>
<p class='pln'>589</p>
<p class='pln'>590</p>
<p class='pln'>591</p>
<p class='stm run hide_run'>592</p>
<p class='stm run hide_run'>593</p>
<p class='stm run hide_run'>594</p>
<p class='pln'>595</p>
<p class='stm run hide_run'>596</p>
<p class='stm run hide_run'>597</p>
<p class='stm run hide_run'>598</p>
<p class='stm run hide_run'>599</p>
<p class='pln'>600</p>
<p class='stm run hide_run'>601</p>
<p class='stm run hide_run'>602</p>
<p class='pln'>603</p>
<p class='stm run hide_run'>604</p>
<p class='pln'>605</p>
<p class='pln'>606</p>
<p class='pln'>607</p>
<p class='stm par run hide_run'>608</p>
<p class='stm run hide_run'>609</p>
<p class='pln'>610</p>
<p class='stm mis'>611</p>
<p class='pln'>612</p>
<p class='stm run hide_run'>613</p>
<p class='pln'>614</p>
<p class='pln'>615</p>
<p class='pln'>616</p>
<p class='stm mis'>617</p>
<p class='stm mis'>618</p>
<p class='pln'>619</p>
<p class='stm run hide_run'>620</p>
<p class='pln'>621</p>
<p class='pln'>622</p>
<p class='pln'>623</p>
<p class='stm mis'>624</p>
<p class='stm mis'>625</p>
<p class='pln'>626</p>
<p class='stm run hide_run'>627</p>
<p class='pln'>628</p>
<p class='pln'>629</p>
<p class='pln'>630</p>
<p class='stm mis'>631</p>
<p class='pln'>632</p>
<p class='stm run hide_run'>633</p>
<p class='pln'>634</p>
<p class='pln'>635</p>
<p class='pln'>636</p>
<p class='pln'>637</p>
<p class='pln'>638</p>
<p class='pln'>639</p>
<p class='stm mis'>640</p>
<p class='stm mis'>641</p>
<p class='pln'>642</p>
<p class='stm mis'>643</p>
<p class='stm mis'>644</p>
<p class='pln'>645</p>
<p class='stm run hide_run'>646</p>
<p class='pln'>647</p>
<p class='pln'>648</p>
<p class='pln'>649</p>
<p class='pln'>650</p>
<p class='pln'>651</p>
<p class='pln'>652</p>
<p class='stm mis'>653</p>
<p class='pln'>654</p>
<p class='pln'>655</p>
<p class='stm run hide_run'>656</p>
<p class='pln'>657</p>
<p class='pln'>658</p>
<p class='pln'>659</p>
<p class='pln'>660</p>
<p class='pln'>661</p>
<p class='pln'>662</p>
<p class='pln'>663</p>
<p class='pln'>664</p>
<p class='stm mis'>665</p>
<p class='stm mis'>666</p>
<p class='stm mis'>667</p>
<p class='stm mis'>668</p>
<p class='stm mis'>669</p>
<p class='pln'>670</p>
<p class='stm mis'>671</p>
<p class='stm mis'>672</p>
<p class='pln'>673</p>
<p class='stm run hide_run'>674</p>
<p class='pln'>675</p>
<p class='pln'>676</p>
<p class='pln'>677</p>
<p class='stm run hide_run'>678</p>
<p class='pln'>679</p>
<p class='stm run hide_run'>680</p>
<p class='pln'>681</p>
<p class='pln'>682</p>
<p class='pln'>683</p>
<p class='pln'>684</p>
<p class='pln'>685</p>
<p class='pln'>686</p>
<p class='stm mis'>687</p>
<p class='pln'>688</p>
<p class='stm run hide_run'>689</p>
<p class='pln'>690</p>
<p class='pln'>691</p>
<p class='pln'>692</p>
<p class='pln'>693</p>
<p class='pln'>694</p>
<p class='pln'>695</p>
<p class='pln'>696</p>
<p class='pln'>697</p>
<p class='pln'>698</p>
<p class='stm mis'>699</p>
<p class='stm mis'>700</p>
<p class='stm mis'>701</p>
<p class='stm mis'>702</p>
<p class='pln'>703</p>
<p class='stm mis'>704</p>
<p class='pln'>705</p>
<p class='stm run hide_run'>706</p>
<p class='pln'>707</p>
<p class='pln'>708</p>
<p class='pln'>709</p>
<p class='pln'>710</p>
<p class='pln'>711</p>
<p class='pln'>712</p>
<p class='pln'>713</p>
<p class='pln'>714</p>
<p class='pln'>715</p>
<p class='pln'>716</p>
<p class='pln'>717</p>
<p class='stm mis'>718</p>
<p class='stm mis'>719</p>
<p class='stm mis'>720</p>
<p class='stm mis'>721</p>
<p class='pln'>722</p>
<p class='stm run hide_run'>723</p>
<p class='pln'>724</p>
<p class='pln'>725</p>
<p class='pln'>726</p>
<p class='pln'>727</p>
<p class='pln'>728</p>
<p class='pln'>729</p>
<p class='stm run hide_run'>730</p>
<p class='pln'>731</p>
<p class='pln'>732</p>
<p class='pln'>733</p>
<p class='pln'>734</p>
<p class='pln'>735</p>
<p class='stm mis'>736</p>
<p class='stm mis'>737</p>
<p class='stm mis'>738</p>
<p class='stm mis'>739</p>
<p class='pln'>740</p>
<p class='stm run hide_run'>741</p>
<p class='pln'>742</p>
<p class='pln'>743</p>
<p class='pln'>744</p>
<p class='stm mis'>745</p>
<p class='stm mis'>746</p>
<p class='pln'>747</p>
<p class='stm run hide_run'>748</p>
<p class='pln'>749</p>
<p class='pln'>750</p>
<p class='pln'>751</p>
<p class='pln'>752</p>
<p class='pln'>753</p>
<p class='pln'>754</p>
<p class='pln'>755</p>
<p class='pln'>756</p>
<p class='pln'>757</p>
<p class='pln'>758</p>
<p class='stm mis'>759</p>
<p class='stm mis'>760</p>
<p class='stm mis'>761</p>
<p class='stm mis'>762</p>
<p class='stm mis'>763</p>
<p class='stm mis'>764</p>
<p class='pln'>765</p>
<p class='stm mis'>766</p>
<p class='stm mis'>767</p>
<p class='pln'>768</p>
<p class='stm mis'>769</p>
<p class='pln'>770</p>
<p class='stm mis'>771</p>
<p class='stm mis'>772</p>
<p class='stm mis'>773</p>
<p class='stm mis'>774</p>
<p class='stm mis'>775</p>
<p class='stm mis'>776</p>
<p class='stm mis'>777</p>
<p class='stm mis'>778</p>
<p class='pln'>779</p>
<p class='stm run hide_run'>780</p>
<p class='pln'>781</p>
<p class='pln'>782</p>
<p class='pln'>783</p>
<p class='stm run hide_run'>784</p>
<p class='pln'>785</p>
<p class='pln'>786</p>
<p class='pln'>787</p>
<p class='pln'>788</p>
<p class='pln'>789</p>
<p class='stm mis'>790</p>
<p class='stm mis'>791</p>
<p class='stm mis'>792</p>
<p class='stm mis'>793</p>
<p class='stm mis'>794</p>
<p class='stm mis'>795</p>
<p class='pln'>796</p>
<p class='pln'>797</p>
<p class='stm mis'>798</p>
<p class='stm mis'>799</p>
<p class='pln'>800</p>
<p class='stm mis'>801</p>
<p class='pln'>802</p>
<p class='stm run hide_run'>803</p>
<p class='pln'>804</p>
<p class='pln'>805</p>
<p class='pln'>806</p>
<p class='stm mis'>807</p>
<p class='stm mis'>808</p>
<p class='stm mis'>809</p>
<p class='stm mis'>810</p>
<p class='stm mis'>811</p>
<p class='stm mis'>812</p>
<p class='pln'>813</p>
<p class='stm run hide_run'>814</p>
<p class='pln'>815</p>
<p class='pln'>816</p>
<p class='pln'>817</p>
<p class='pln'>818</p>
<p class='stm mis'>819</p>
<p class='stm mis'>820</p>
<p class='pln'>821</p>
<p class='stm mis'>822</p>
<p class='stm mis'>823</p>
<p class='pln'>824</p>
<p class='stm run hide_run'>825</p>
<p class='pln'>826</p>
<p class='pln'>827</p>
<p class='pln'>828</p>
<p class='pln'>829</p>
<p class='pln'>830</p>
<p class='pln'>831</p>
<p class='stm mis'>832</p>
<p class='stm mis'>833</p>
<p class='stm mis'>834</p>
<p class='pln'>835</p>
<p class='pln'>836</p>
<p class='pln'>837</p>
<p class='pln'>838</p>
<p class='pln'>839</p>
<p class='stm run hide_run'>840</p>
<p class='pln'>841</p>
<p class='pln'>842</p>
<p class='pln'>843</p>
<p class='pln'>844</p>
<p class='pln'>845</p>
<p class='stm run hide_run'>846</p>
<p class='pln'>847</p>
<p class='pln'>848</p>
<p class='pln'>849</p>
<p class='pln'>850</p>
<p class='stm mis'>851</p>
<p class='pln'>852</p>
<p class='stm run hide_run'>853</p>
<p class='pln'>854</p>
<p class='pln'>855</p>
<p class='pln'>856</p>
<p class='pln'>857</p>
<p class='stm mis'>858</p>
<p class='pln'>859</p>
<p class='stm mis'>860</p>
<p class='pln'>861</p>
<p class='pln'>862</p>
<p class='pln'>863</p>
<p class='pln'>864</p>
<p class='stm run hide_run'>865</p>
<p class='pln'>866</p>
<p class='stm run hide_run'>867</p>
<p class='pln'>868</p>
<p class='pln'>869</p>
<p class='pln'>870</p>
<p class='pln'>871</p>
<p class='pln'>872</p>
<p class='stm mis'>873</p>
<p class='stm mis'>874</p>
<p class='stm mis'>875</p>
<p class='pln'>876</p>
<p class='pln'>877</p>
<p class='stm mis'>878</p>
<p class='pln'>879</p>
<p class='stm run hide_run'>880</p>
<p class='pln'>881</p>
<p class='pln'>882</p>
<p class='pln'>883</p>
<p class='pln'>884</p>
<p class='stm mis'>885</p>
<p class='pln'>886</p>
<p class='stm run hide_run'>887</p>
<p class='pln'>888</p>
<p class='pln'>889</p>
<p class='pln'>890</p>
<p class='pln'>891</p>
<p class='stm run hide_run'>892</p>
<p class='pln'>893</p>
<p class='pln'>894</p>
<p class='pln'>895</p>
<p class='stm run hide_run'>896</p>
<p class='stm run hide_run'>897</p>
<p class='stm run hide_run'>898</p>
<p class='stm run hide_run'>899</p>
<p class='pln'>900</p>
<p class='stm run hide_run'>901</p>
<p class='pln'>902</p>
<p class='pln'>903</p>
<p class='pln'>904</p>
<p class='pln'>905</p>
<p class='pln'>906</p>
<p class='pln'>907</p>
<p class='pln'>908</p>
<p class='pln'>909</p>
<p class='pln'>910</p>
<p class='pln'>911</p>
<p class='stm run hide_run'>912</p>
<p class='stm run hide_run'>913</p>
<p class='stm run hide_run'>914</p>
<p class='stm run hide_run'>915</p>
<p class='stm run hide_run'>916</p>
<p class='stm par run hide_run'>917</p>
<p class='stm mis'>918</p>
<p class='stm mis'>919</p>
<p class='stm mis'>920</p>
<p class='stm mis'>921</p>
<p class='stm mis'>922</p>
<p class='stm mis'>923</p>
<p class='pln'>924</p>
<p class='stm run hide_run'>925</p>
<p class='stm run hide_run'>926</p>
<p class='stm run hide_run'>927</p>
<p class='stm run hide_run'>928</p>
<p class='pln'>929</p>
<p class='stm run hide_run'>930</p>
<p class='stm run hide_run'>931</p>
<p class='pln'>932</p>
<p class='stm run hide_run'>933</p>
<p class='pln'>934</p>
<p class='pln'>935</p>
<p class='pln'>936</p>
<p class='pln'>937</p>
<p class='stm run hide_run'>938</p>
<p class='stm run hide_run'>939</p>
<p class='stm run hide_run'>940</p>
<p class='stm par run hide_run'>941</p>
<p class='stm mis'>942</p>
<p class='stm mis'>943</p>
<p class='stm mis'>944</p>
<p class='pln'>945</p>
<p class='stm mis'>946</p>
<p class='stm mis'>947</p>
<p class='stm mis'>948</p>
<p class='pln'>949</p>
<p class='stm mis'>950</p>
<p class='stm mis'>951</p>
<p class='stm mis'>952</p>
<p class='stm par run hide_run'>953</p>
<p class='stm run hide_run'>954</p>
<p class='stm run hide_run'>955</p>
<p class='pln'>956</p>
<p class='stm run hide_run'>957</p>
<p class='pln'>958</p>
<p class='pln'>959</p>
<p class='pln'>960</p>
<p class='pln'>961</p>
<p class='stm mis'>962</p>
<p class='stm mis'>963</p>
<p class='stm mis'>964</p>
<p class='pln'>965</p>
<p class='pln'>966</p>
<p class='stm mis'>967</p>
<p class='stm mis'>968</p>
<p class='stm mis'>969</p>
<p class='pln'>970</p>
<p class='pln'>971</p>
<p class='pln'>972</p>
<p class='pln'>973</p>
<p class='pln'>974</p>
<p class='stm run hide_run'>975</p>
<p class='pln'>976</p>
<p class='pln'>977</p>
<p class='pln'>978</p>
<p class='pln'>979</p>
<p class='pln'>980</p>
<p class='pln'>981</p>
<p class='pln'>982</p>
<p class='pln'>983</p>
<p class='pln'>984</p>
<p class='pln'>985</p>
<p class='pln'>986</p>
<p class='pln'>987</p>
<p class='pln'>988</p>
<p class='pln'>989</p>
<p class='stm run hide_run'>990</p>
<p class='pln'>991</p>
<p class='pln'>992</p>
<p class='pln'>993</p>
<p class='stm run hide_run'>994</p>
<p class='stm run hide_run'>995</p>
<p class='stm run hide_run'>996</p>
<p class='stm run hide_run'>997</p>
<p class='stm run hide_run'>998</p>
<p class='stm run hide_run'>999</p>
<p class='stm run hide_run'>1000</p>
<p class='pln'>1001</p>
<p class='stm run hide_run'>1002</p>
<p class='pln'>1003</p>
<p class='pln'>1004</p>
<p class='pln'>1005</p>
<p class='stm run hide_run'>1006</p>
<p class='pln'>1007</p>
<p class='stm run hide_run'>1008</p>
<p class='pln'>1009</p>
<p class='pln'>1010</p>
<p class='pln'>1011</p>
<p class='pln'>1012</p>
<p class='pln'>1013</p>
<p class='pln'>1014</p>
<p class='pln'>1015</p>
<p class='pln'>1016</p>
<p class='stm mis'>1017</p>
<p class='stm mis'>1018</p>
<p class='pln'>1019</p>
<p class='stm run hide_run'>1020</p>
<p class='pln'>1021</p>
<p class='pln'>1022</p>
<p class='pln'>1023</p>
<p class='pln'>1024</p>
<p class='pln'>1025</p>
<p class='pln'>1026</p>
<p class='pln'>1027</p>
<p class='pln'>1028</p>
<p class='stm mis'>1029</p>
<p class='stm mis'>1030</p>
<p class='pln'>1031</p>
<p class='stm run hide_run'>1032</p>
<p class='pln'>1033</p>
<p class='pln'>1034</p>
<p class='pln'>1035</p>
<p class='pln'>1036</p>
<p class='pln'>1037</p>
<p class='pln'>1038</p>
<p class='pln'>1039</p>
<p class='pln'>1040</p>
<p class='stm mis'>1041</p>
<p class='stm mis'>1042</p>
<p class='pln'>1043</p>
<p class='stm run hide_run'>1044</p>
<p class='pln'>1045</p>
<p class='stm run hide_run'>1046</p>
<p class='pln'>1047</p>
<p class='pln'>1048</p>
<p class='pln'>1049</p>
<p class='pln'>1050</p>
<p class='pln'>1051</p>
<p class='pln'>1052</p>
<p class='pln'>1053</p>
<p class='pln'>1054</p>
<p class='stm mis'>1055</p>
<p class='stm mis'>1056</p>
<p class='pln'>1057</p>
<p class='stm run hide_run'>1058</p>
<p class='pln'>1059</p>
<p class='pln'>1060</p>
<p class='pln'>1061</p>
<p class='stm mis'>1062</p>
<p class='pln'>1063</p>
<p class='stm run hide_run'>1064</p>
<p class='pln'>1065</p>
<p class='pln'>1066</p>
<p class='pln'>1067</p>
<p class='pln'>1068</p>
<p class='pln'>1069</p>
<p class='pln'>1070</p>
<p class='pln'>1071</p>
<p class='pln'>1072</p>
<p class='stm mis'>1073</p>
<p class='stm mis'>1074</p>
<p class='pln'>1075</p>
<p class='stm run hide_run'>1076</p>
<p class='pln'>1077</p>
<p class='stm run hide_run'>1078</p>
<p class='pln'>1079</p>
<p class='pln'>1080</p>
<p class='pln'>1081</p>
<p class='pln'>1082</p>
<p class='pln'>1083</p>
<p class='pln'>1084</p>
<p class='pln'>1085</p>
<p class='pln'>1086</p>
<p class='stm mis'>1087</p>
<p class='stm mis'>1088</p>
<p class='stm mis'>1089</p>
<p class='pln'>1090</p>
<p class='stm mis'>1091</p>
<p class='stm mis'>1092</p>
<p class='stm mis'>1093</p>
<p class='pln'>1094</p>
<p class='stm run hide_run'>1095</p>
<p class='pln'>1096</p>
<p class='pln'>1097</p>
<p class='pln'>1098</p>
<p class='pln'>1099</p>
<p class='stm mis'>1100</p>
<p class='stm mis'>1101</p>
<p class='stm mis'>1102</p>
<p class='stm mis'>1103</p>
<p class='stm mis'>1104</p>
<p class='stm mis'>1105</p>
<p class='stm mis'>1106</p>
<p class='stm mis'>1107</p>
<p class='stm mis'>1108</p>
<p class='stm mis'>1109</p>
<p class='stm mis'>1110</p>
<p class='pln'>1111</p>
<p class='stm run hide_run'>1112</p>
<p class='pln'>1113</p>
<p class='pln'>1114</p>
<p class='pln'>1115</p>
<p class='pln'>1116</p>
<p class='stm mis'>1117</p>
<p class='stm mis'>1118</p>
<p class='stm mis'>1119</p>
<p class='stm mis'>1120</p>
<p class='stm mis'>1121</p>
<p class='stm mis'>1122</p>
<p class='stm mis'>1123</p>
<p class='pln'>1124</p>
<p class='stm run hide_run'>1125</p>
<p class='pln'>1126</p>
<p class='pln'>1127</p>
<p class='pln'>1128</p>
<p class='pln'>1129</p>
<p class='stm mis'>1130</p>
<p class='pln'>1131</p>
<p class='pln'>1132</p>
<p class='stm mis'>1133</p>
<p class='stm mis'>1134</p>
<p class='stm mis'>1135</p>
<p class='stm mis'>1136</p>
<p class='pln'>1137</p>
<p class='stm mis'>1138</p>
<p class='stm mis'>1139</p>
<p class='stm mis'>1140</p>
<p class='stm mis'>1141</p>
<p class='stm mis'>1142</p>
<p class='stm mis'>1143</p>
<p class='pln'>1144</p>
<p class='stm run hide_run'>1145</p>
<p class='pln'>1146</p>
<p class='pln'>1147</p>
<p class='pln'>1148</p>
<p class='pln'>1149</p>
<p class='pln'>1150</p>
<p class='pln'>1151</p>
<p class='stm mis'>1152</p>
<p class='stm mis'>1153</p>
<p class='pln'>1154</p>
<p class='stm run hide_run'>1155</p>
<p class='pln'>1156</p>
<p class='pln'>1157</p>
<p class='pln'>1158</p>
<p class='stm par run hide_run'>1159</p>
<p class='stm run hide_run'>1160</p>
<p class='pln'>1161</p>
<p class='stm run hide_run'>1162</p>
<p class='pln'>1163</p>
<p class='pln'>1164</p>
<p class='pln'>1165</p>
<p class='stm mis'>1166</p>
<p class='pln'>1167</p>
<p class='stm mis'>1168</p>
<p class='stm mis'>1169</p>
<p class='stm mis'>1170</p>
<p class='pln'>1171</p>
<p class='stm mis'>1172</p>
<p class='pln'>1173</p>
<p class='stm run hide_run'>1174</p>
<p class='pln'>1175</p>
<p class='pln'>1176</p>
<p class='pln'>1177</p>
<p class='pln'>1178</p>
<p class='pln'>1179</p>
<p class='pln'>1180</p>
<p class='pln'>1181</p>
<p class='pln'>1182</p>
<p class='pln'>1183</p>
<p class='stm mis'>1184</p>
<p class='stm mis'>1185</p>
<p class='stm mis'>1186</p>
<p class='stm mis'>1187</p>
<p class='stm mis'>1188</p>
<p class='stm mis'>1189</p>
<p class='stm mis'>1190</p>
<p class='stm mis'>1191</p>
<p class='stm mis'>1192</p>
<p class='pln'>1193</p>
<p class='stm mis'>1194</p>
<p class='stm mis'>1195</p>
<p class='stm mis'>1196</p>
<p class='pln'>1197</p>
<p class='stm mis'>1198</p>
<p class='pln'>1199</p>
<p class='stm run hide_run'>1200</p>
<p class='pln'>1201</p>
<p class='pln'>1202</p>
<p class='pln'>1203</p>
<p class='pln'>1204</p>
<p class='pln'>1205</p>
<p class='pln'>1206</p>
<p class='stm mis'>1207</p>
<p class='stm mis'>1208</p>
<p class='stm mis'>1209</p>
<p class='stm mis'>1210</p>
<p class='stm mis'>1211</p>
<p class='stm mis'>1212</p>
<p class='pln'>1213</p>
<p class='stm run hide_run'>1214</p>
<p class='pln'>1215</p>
<p class='pln'>1216</p>
<p class='pln'>1217</p>
<p class='stm mis'>1218</p>
<p class='stm mis'>1219</p>
<p class='stm mis'>1220</p>
<p class='pln'>1221</p>
<p class='stm run hide_run'>1222</p>
<p class='pln'>1223</p>
<p class='pln'>1224</p>
<p class='pln'>1225</p>
<p class='pln'>1226</p>
<p class='pln'>1227</p>
<p class='stm run hide_run'>1228</p>
<p class='pln'>1229</p>
<p class='pln'>1230</p>
<p class='pln'>1231</p>
<p class='stm run hide_run'>1232</p>
<p class='pln'>1233</p>
<p class='stm run hide_run'>1234</p>
<p class='pln'>1235</p>
<p class='stm run hide_run'>1236</p>
<p class='pln'>1237</p>
<p class='pln'>1238</p>
<p class='pln'>1239</p>
<p class='pln'>1240</p>
<p class='pln'>1241</p>
<p class='stm run hide_run'>1242</p>
<p class='pln'>1243</p>
<p class='pln'>1244</p>
<p class='pln'>1245</p>
<p class='pln'>1246</p>
<p class='pln'>1247</p>
<p class='pln'>1248</p>
<p class='pln'>1249</p>
<p class='pln'>1250</p>
<p class='pln'>1251</p>
<p class='pln'>1252</p>
<p class='stm mis'>1253</p>
<p class='stm mis'>1254</p>
<p class='pln'>1255</p>
<p class='stm run hide_run'>1256</p>
<p class='pln'>1257</p>
<p class='pln'>1258</p>
<p class='pln'>1259</p>
<p class='pln'>1260</p>
<p class='pln'>1261</p>
<p class='pln'>1262</p>
<p class='pln'>1263</p>
<p class='pln'>1264</p>
<p class='pln'>1265</p>
<p class='stm mis'>1266</p>
<p class='stm mis'>1267</p>
<p class='pln'>1268</p>
<p class='stm run hide_run'>1269</p>
<p class='pln'>1270</p>
<p class='pln'>1271</p>
<p class='pln'>1272</p>
<p class='pln'>1273</p>
<p class='stm mis'>1274</p>
<p class='stm mis'>1275</p>
<p class='pln'>1276</p>
<p class='stm run hide_run'>1277</p>
<p class='pln'>1278</p>
<p class='pln'>1279</p>
<p class='pln'>1280</p>
<p class='pln'>1281</p>
<p class='stm mis'>1282</p>
<p class='stm mis'>1283</p>
<p class='pln'>1284</p>
<p class='stm run hide_run'>1285</p>
<p class='pln'>1286</p>
<p class='pln'>1287</p>
<p class='pln'>1288</p>
<p class='pln'>1289</p>
<p class='stm mis'>1290</p>
<p class='stm mis'>1291</p>
<p class='pln'>1292</p>
<p class='stm run hide_run'>1293</p>
<p class='pln'>1294</p>
<p class='pln'>1295</p>
<p class='pln'>1296</p>
<p class='pln'>1297</p>
<p class='stm mis'>1298</p>
<p class='stm mis'>1299</p>
<p class='pln'>1300</p>
<p class='stm run hide_run'>1301</p>
<p class='pln'>1302</p>
<p class='pln'>1303</p>
<p class='pln'>1304</p>
<p class='pln'>1305</p>
<p class='stm mis'>1306</p>
<p class='stm mis'>1307</p>
<p class='stm mis'>1308</p>
<p class='pln'>1309</p>
<p class='stm run hide_run'>1310</p>
<p class='pln'>1311</p>
<p class='pln'>1312</p>
<p class='pln'>1313</p>
<p class='pln'>1314</p>
<p class='stm mis'>1315</p>
<p class='stm mis'>1316</p>
<p class='pln'>1317</p>
<p class='stm run hide_run'>1318</p>
<p class='pln'>1319</p>
<p class='pln'>1320</p>
<p class='pln'>1321</p>
<p class='pln'>1322</p>
<p class='stm mis'>1323</p>
<p class='stm mis'>1324</p>
<p class='pln'>1325</p>
<p class='stm run hide_run'>1326</p>
<p class='stm run hide_run'>1327</p>
<p class='stm run hide_run'>1328</p>
<p class='pln'>1329</p>
<p class='pln'>1330</p>
<p class='pln'>1331</p>
<p class='pln'>1332</p>
<p class='pln'>1333</p>
<p class='stm run hide_run'>1334</p>
<p class='pln'>1335</p>
<p class='stm run hide_run'>1336</p>
<p class='pln'>1337</p>
<p class='pln'>1338</p>
<p class='pln'>1339</p>
<p class='pln'>1340</p>
<p class='pln'>1341</p>
<p class='pln'>1342</p>
<p class='pln'>1343</p>
<p class='pln'>1344</p>
<p class='pln'>1345</p>
<p class='pln'>1346</p>
<p class='pln'>1347</p>
<p class='pln'>1348</p>
<p class='pln'>1349</p>
<p class='pln'>1350</p>
<p class='pln'>1351</p>
<p class='pln'>1352</p>
<p class='pln'>1353</p>
<p class='pln'>1354</p>
<p class='pln'>1355</p>
<p class='pln'>1356</p>
<p class='pln'>1357</p>
<p class='pln'>1358</p>
<p class='pln'>1359</p>
<p class='pln'>1360</p>
<p class='pln'>1361</p>
<p class='pln'>1362</p>
<p class='pln'>1363</p>
<p class='pln'>1364</p>
<p class='pln'>1365</p>
<p class='pln'>1366</p>
<p class='pln'>1367</p>
<p class='stm mis'>1368</p>
<p class='stm mis'>1369</p>
<p class='stm mis'>1370</p>
<p class='stm mis'>1371</p>
<p class='stm mis'>1372</p>
<p class='pln'>1373</p>
<p class='stm mis'>1374</p>
<p class='stm mis'>1375</p>
<p class='stm mis'>1376</p>
<p class='stm mis'>1377</p>
<p class='stm mis'>1378</p>
<p class='stm mis'>1379</p>
<p class='stm mis'>1380</p>
<p class='stm mis'>1381</p>
<p class='stm mis'>1382</p>
<p class='stm mis'>1383</p>
<p class='pln'>1384</p>
<p class='pln'>1385</p>
<p class='pln'>1386</p>
<p class='pln'>1387</p>
<p class='pln'>1388</p>
<p class='pln'>1389</p>
<p class='stm run hide_run'>1390</p>
<p class='pln'>1391</p>
<p class='pln'>1392</p>
<p class='pln'>1393</p>
<p class='pln'>1394</p>
<p class='pln'>1395</p>
<p class='stm par run hide_run'>1396</p>
<p class='stm run hide_run'>1397</p>
<p class='pln'>1398</p>
<p class='stm mis'>1399</p>
<p class='pln'>1400</p>
<p class='pln'>1401</p>
<p class='pln'>1402</p>
<p class='pln'>1403</p>
<p class='pln'>1404</p>
<p class='pln'>1405</p>
<p class='pln'>1406</p>
<p class='pln'>1407</p>
<p class='pln'>1408</p>
<p class='pln'>1409</p>
<p class='stm run hide_run'>1410</p>
<p class='pln'>1411</p>
<p class='pln'>1412</p>
<p class='pln'>1413</p>
<p class='stm mis'>1414</p>
<p class='stm mis'>1415</p>
<p class='stm mis'>1416</p>
<p class='pln'>1417</p>
<p class='stm run hide_run'>1418</p>
<p class='pln'>1419</p>
<p class='stm run hide_run'>1420</p>
<p class='pln'>1421</p>
<p class='pln'>1422</p>
<p class='pln'>1423</p>
<p class='stm mis'>1424</p>
<p class='stm mis'>1425</p>
<p class='stm mis'>1426</p>
<p class='pln'>1427</p>
<p class='stm run hide_run'>1428</p>
<p class='pln'>1429</p>
<p class='pln'>1430</p>
<p class='pln'>1431</p>
<p class='pln'>1432</p>
<p class='stm mis'>1433</p>
<p class='pln'>1434</p>
<p class='stm run hide_run'>1435</p>
<p class='pln'>1436</p>
<p class='pln'>1437</p>
<p class='pln'>1438</p>
<p class='stm mis'>1439</p>
<p class='stm mis'>1440</p>
<p class='stm mis'>1441</p>
<p class='pln'>1442</p>
<p class='stm run hide_run'>1443</p>
<p class='pln'>1444</p>
<p class='stm run hide_run'>1445</p>
<p class='pln'>1446</p>
<p class='pln'>1447</p>
<p class='pln'>1448</p>
<p class='stm mis'>1449</p>
<p class='stm mis'>1450</p>
<p class='stm mis'>1451</p>
<p class='pln'>1452</p>
<p class='stm run hide_run'>1453</p>
<p class='pln'>1454</p>
<p class='pln'>1455</p>
<p class='pln'>1456</p>
<p class='stm mis'>1457</p>
<p class='stm mis'>1458</p>
<p class='stm mis'>1459</p>
<p class='pln'>1460</p>
<p class='stm run hide_run'>1461</p>
<p class='pln'>1462</p>
<p class='pln'>1463</p>
<p class='pln'>1464</p>
<p class='stm mis'>1465</p>
<p class='stm mis'>1466</p>
<p class='stm mis'>1467</p>
<p class='pln'>1468</p>
<p class='stm run hide_run'>1469</p>
<p class='pln'>1470</p>
<p class='pln'>1471</p>
<p class='pln'>1472</p>
<p class='stm mis'>1473</p>
<p class='pln'>1474</p>
<p class='stm run hide_run'>1475</p>
<p class='pln'>1476</p>
<p class='pln'>1477</p>
<p class='pln'>1478</p>
<p class='pln'>1479</p>
<p class='pln'>1480</p>
<p class='pln'>1481</p>
<p class='stm mis'>1482</p>
<p class='pln'>1483</p>
<p class='pln'>1484</p>
<p class='stm mis'>1485</p>
<p class='stm mis'>1486</p>
<p class='stm mis'>1487</p>
<p class='stm mis'>1488</p>
<p class='stm mis'>1489</p>
<p class='stm mis'>1490</p>
<p class='pln'>1491</p>
<p class='pln'>1492</p>
<p class='pln'>1493</p>
<p class='stm run hide_run'>1494</p>
<p class='stm run hide_run'>1495</p>
<p class='stm run hide_run'>1496</p>
<p class='stm mis'>1497</p>
<p class='stm mis'>1498</p>
<p class='stm mis'>1499</p>
<p class='stm mis'>1500</p>
<p class='pln'>1501</p>
<p class='stm mis'>1502</p>
<p class='pln'>1503</p>
<p class='stm mis'>1504</p>
    
</td>
<td class='text' valign='top'>
<p class='pln'><span class='com'># Copyright 2001-2009 by Vinay Sajip. All Rights Reserved.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># Permission to use, copy, modify, and distribute this software and its</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># documentation for any purpose and without fee is hereby granted,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># provided that the above copyright notice appear in all copies and that</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># both that copyright notice and this permission notice appear in</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># supporting documentation, and that the name of Vinay Sajip</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># not be used in advertising or publicity pertaining to distribution</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># of the software without specific, written prior permission.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># VINAY SAJIP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># VINAY SAJIP BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>Logging package for Python. Based on PEP 282 and comments thereto in</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>comp.lang.python, and influenced by Apache&#39;s log4j system.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>Copyright (C) 2001-2009 Vinay Sajip. All Rights Reserved.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>To use, simply &#39;import logging&#39; and log away!</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='nam'>__all__</span> <span class='op'>=</span> <span class='op'>[</span><span class='str'>&#39;BASIC_FORMAT&#39;</span><span class='op'>,</span> <span class='str'>&#39;BufferingFormatter&#39;</span><span class='op'>,</span> <span class='str'>&#39;CRITICAL&#39;</span><span class='op'>,</span> <span class='str'>&#39;DEBUG&#39;</span><span class='op'>,</span> <span class='str'>&#39;ERROR&#39;</span><span class='op'>,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; <span class='str'>&#39;FATAL&#39;</span><span class='op'>,</span> <span class='str'>&#39;FileHandler&#39;</span><span class='op'>,</span> <span class='str'>&#39;Filter&#39;</span><span class='op'>,</span> <span class='str'>&#39;Filterer&#39;</span><span class='op'>,</span> <span class='str'>&#39;Formatter&#39;</span><span class='op'>,</span> <span class='str'>&#39;Handler&#39;</span><span class='op'>,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; <span class='str'>&#39;INFO&#39;</span><span class='op'>,</span> <span class='str'>&#39;LogRecord&#39;</span><span class='op'>,</span> <span class='str'>&#39;Logger&#39;</span><span class='op'>,</span> <span class='str'>&#39;Manager&#39;</span><span class='op'>,</span> <span class='str'>&#39;NOTSET&#39;</span><span class='op'>,</span> <span class='str'>&#39;PlaceHolder&#39;</span><span class='op'>,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; <span class='str'>&#39;RootLogger&#39;</span><span class='op'>,</span> <span class='str'>&#39;StreamHandler&#39;</span><span class='op'>,</span> <span class='str'>&#39;WARN&#39;</span><span class='op'>,</span> <span class='str'>&#39;WARNING&#39;</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>import</span> <span class='nam'>sys</span><span class='op'>,</span> <span class='nam'>os</span><span class='op'>,</span> <span class='nam'>types</span><span class='op'>,</span> <span class='nam'>time</span><span class='op'>,</span> <span class='nam'>string</span><span class='op'>,</span> <span class='nam'>cStringIO</span><span class='op'>,</span> <span class='nam'>traceback</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>try</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>import</span> <span class='nam'>codecs</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='key'>except</span> <span class='nam'>ImportError</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='nam'>codecs</span> <span class='op'>=</span> <span class='nam'>None</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>try</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>import</span> <span class='nam'>thread</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>import</span> <span class='nam'>threading</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='key'>except</span> <span class='nam'>ImportError</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='nam'>thread</span> <span class='op'>=</span> <span class='nam'>None</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='nam'>__author__</span>&nbsp; <span class='op'>=</span> <span class='str'>&quot;Vinay Sajip &lt;vinay_sajip@red-dove.com&gt;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='nam'>__status__</span>&nbsp; <span class='op'>=</span> <span class='str'>&quot;production&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='nam'>__version__</span> <span class='op'>=</span> <span class='str'>&quot;0.5.0.5&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='nam'>__date__</span>&nbsp; &nbsp; <span class='op'>=</span> <span class='str'>&quot;17 February 2009&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#---------------------------------------------------------------------------</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#&nbsp;&nbsp; Miscellaneous module data</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#---------------------------------------------------------------------------</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># _srcfile is used when walking the stack to check when we&#39;ve got the first</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># caller stack frame.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#</span><span class='strut'>&nbsp;</span></p>
<p class='stm par run hide_run'><span class='annotate' title='no jump to this line number'>58</span><span class='key'>if</span> <span class='nam'>hasattr</span><span class='op'>(</span><span class='nam'>sys</span><span class='op'>,</span> <span class='str'>&#39;frozen&#39;</span><span class='op'>)</span><span class='op'>:</span> <span class='com'>#support for py2exe</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='nam'>_srcfile</span> <span class='op'>=</span> <span class='str'>&quot;logging%s__init__%s&quot;</span> <span class='op'>%</span> <span class='op'>(</span><span class='nam'>os</span><span class='op'>.</span><span class='nam'>sep</span><span class='op'>,</span> <span class='nam'>__file__</span><span class='op'>[</span><span class='op'>-</span><span class='num'>4</span><span class='op'>:</span><span class='op'>]</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm par run hide_run'><span class='annotate' title='no jump to this line number'>62</span><span class='key'>elif</span> <span class='nam'>string</span><span class='op'>.</span><span class='nam'>lower</span><span class='op'>(</span><span class='nam'>__file__</span><span class='op'>[</span><span class='op'>-</span><span class='num'>4</span><span class='op'>:</span><span class='op'>]</span><span class='op'>)</span> <span class='key'>in</span> <span class='op'>[</span><span class='str'>&#39;.pyc&#39;</span><span class='op'>,</span> <span class='str'>&#39;.pyo&#39;</span><span class='op'>]</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='nam'>_srcfile</span> <span class='op'>=</span> <span class='nam'>__file__</span><span class='op'>[</span><span class='op'>:</span><span class='op'>-</span><span class='num'>4</span><span class='op'>]</span> <span class='op'>+</span> <span class='str'>&#39;.py&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='key'>else</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='nam'>_srcfile</span> <span class='op'>=</span> <span class='nam'>__file__</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='nam'>_srcfile</span> <span class='op'>=</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>.</span><span class='nam'>normcase</span><span class='op'>(</span><span class='nam'>_srcfile</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># next bit filched from 1.5.2&#39;s inspect.py</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>def</span> <span class='nam'>currentframe</span><span class='op'>(</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;Return the frame object for the caller&#39;s stack frame.&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>try</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>raise</span> <span class='nam'>Exception</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>except</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>sys</span><span class='op'>.</span><span class='nam'>exc_traceback</span><span class='op'>.</span><span class='nam'>tb_frame</span><span class='op'>.</span><span class='nam'>f_back</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm par run hide_run'><span class='annotate' title='no jump to this line number'>exit</span><span class='key'>if</span> <span class='nam'>hasattr</span><span class='op'>(</span><span class='nam'>sys</span><span class='op'>,</span> <span class='str'>&#39;_getframe&#39;</span><span class='op'>)</span><span class='op'>:</span> <span class='nam'>currentframe</span> <span class='op'>=</span> <span class='key'>lambda</span><span class='op'>:</span> <span class='nam'>sys</span><span class='op'>.</span><span class='nam'>_getframe</span><span class='op'>(</span><span class='num'>3</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># done filching</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># _srcfile is only used in conjunction with sys._getframe().</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># To provide compatibility with older versions of Python, set _srcfile</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># to None if _getframe() is not available; this value will prevent</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># findCaller() from being called.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#if not hasattr(sys, &quot;_getframe&quot;):</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#&nbsp; &nbsp; _srcfile = None</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#_startTime is used as the base when calculating the relative time of events</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='nam'>_startTime</span> <span class='op'>=</span> <span class='nam'>time</span><span class='op'>.</span><span class='nam'>time</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#raiseExceptions is used to see if exceptions during handling should be</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#propagated</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='nam'>raiseExceptions</span> <span class='op'>=</span> <span class='num'>1</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># If you don&#39;t want threading information in the log, set this to zero</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='nam'>logThreads</span> <span class='op'>=</span> <span class='num'>1</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># If you don&#39;t want multiprocessing information in the log, set this to zero</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='nam'>logMultiprocessing</span> <span class='op'>=</span> <span class='num'>1</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># If you don&#39;t want process information in the log, set this to zero</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='nam'>logProcesses</span> <span class='op'>=</span> <span class='num'>1</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#---------------------------------------------------------------------------</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#&nbsp;&nbsp; Level related stuff</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#---------------------------------------------------------------------------</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># Default levels and level names, these can be replaced with any positive set</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># of values having corresponding names. There is a pseudo-level, NOTSET, which</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># is only really there as a lower limit for user-defined levels. Handlers and</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># loggers are initialized with NOTSET so that they will log all messages, even</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># at user-defined levels.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='nam'>CRITICAL</span> <span class='op'>=</span> <span class='num'>50</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='nam'>FATAL</span> <span class='op'>=</span> <span class='nam'>CRITICAL</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='nam'>ERROR</span> <span class='op'>=</span> <span class='num'>40</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='nam'>WARNING</span> <span class='op'>=</span> <span class='num'>30</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='nam'>WARN</span> <span class='op'>=</span> <span class='nam'>WARNING</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='nam'>INFO</span> <span class='op'>=</span> <span class='num'>20</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='nam'>DEBUG</span> <span class='op'>=</span> <span class='num'>10</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='nam'>NOTSET</span> <span class='op'>=</span> <span class='num'>0</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='nam'>_levelNames</span> <span class='op'>=</span> <span class='op'>{</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='nam'>CRITICAL</span> <span class='op'>:</span> <span class='str'>&#39;CRITICAL&#39;</span><span class='op'>,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='nam'>ERROR</span> <span class='op'>:</span> <span class='str'>&#39;ERROR&#39;</span><span class='op'>,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='nam'>WARNING</span> <span class='op'>:</span> <span class='str'>&#39;WARNING&#39;</span><span class='op'>,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='nam'>INFO</span> <span class='op'>:</span> <span class='str'>&#39;INFO&#39;</span><span class='op'>,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='nam'>DEBUG</span> <span class='op'>:</span> <span class='str'>&#39;DEBUG&#39;</span><span class='op'>,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='nam'>NOTSET</span> <span class='op'>:</span> <span class='str'>&#39;NOTSET&#39;</span><span class='op'>,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&#39;CRITICAL&#39;</span> <span class='op'>:</span> <span class='nam'>CRITICAL</span><span class='op'>,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&#39;ERROR&#39;</span> <span class='op'>:</span> <span class='nam'>ERROR</span><span class='op'>,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&#39;WARN&#39;</span> <span class='op'>:</span> <span class='nam'>WARNING</span><span class='op'>,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&#39;WARNING&#39;</span> <span class='op'>:</span> <span class='nam'>WARNING</span><span class='op'>,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&#39;INFO&#39;</span> <span class='op'>:</span> <span class='nam'>INFO</span><span class='op'>,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&#39;DEBUG&#39;</span> <span class='op'>:</span> <span class='nam'>DEBUG</span><span class='op'>,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&#39;NOTSET&#39;</span> <span class='op'>:</span> <span class='nam'>NOTSET</span><span class='op'>,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='op'>}</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>def</span> <span class='nam'>getLevelName</span><span class='op'>(</span><span class='nam'>level</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Return the textual representation of logging level &#39;level&#39;.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; If the level is one of the predefined levels (CRITICAL, ERROR, WARNING,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; INFO, DEBUG) then you get the corresponding string. If you have</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; associated levels with names using addLevelName then the name you have</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; associated with &#39;level&#39; is returned.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; If a numeric value corresponding to one of the defined levels is passed</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; in, the corresponding string representation is returned.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Otherwise, the string &quot;Level %s&quot; % level is returned.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>_levelNames</span><span class='op'>.</span><span class='nam'>get</span><span class='op'>(</span><span class='nam'>level</span><span class='op'>,</span> <span class='op'>(</span><span class='str'>&quot;Level %s&quot;</span> <span class='op'>%</span> <span class='nam'>level</span><span class='op'>)</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>def</span> <span class='nam'>addLevelName</span><span class='op'>(</span><span class='nam'>level</span><span class='op'>,</span> <span class='nam'>levelName</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Associate &#39;levelName&#39; with &#39;level&#39;.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; This is used when converting levels to text during message formatting.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='nam'>_acquireLock</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>try</span><span class='op'>:</span>&nbsp; &nbsp; <span class='com'>#unlikely to cause an exception, but you never know...</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>_levelNames</span><span class='op'>[</span><span class='nam'>level</span><span class='op'>]</span> <span class='op'>=</span> <span class='nam'>levelName</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>_levelNames</span><span class='op'>[</span><span class='nam'>levelName</span><span class='op'>]</span> <span class='op'>=</span> <span class='nam'>level</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='key'>finally</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>_releaseLock</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#---------------------------------------------------------------------------</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#&nbsp;&nbsp; Thread-related stuff</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#---------------------------------------------------------------------------</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#_lock is used to serialize access to shared data structures in this module.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#This needs to be an RLock because fileConfig() creates Handlers and so</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#might arbitrary user threads. Since Handler.__init__() updates the shared</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#dictionary _handlers, it needs to acquire the lock. But if configuring,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#the lock would already have been acquired - so we need an RLock.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#The same argument applies to Loggers and Manager.loggerDict.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='nam'>_lock</span> <span class='op'>=</span> <span class='nam'>None</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>def</span> <span class='nam'>_acquireLock</span><span class='op'>(</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Acquire the module-level lock for serializing access to shared data.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; This should be released with _releaseLock().</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='key'>global</span> <span class='nam'>_lock</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>if</span> <span class='op'>(</span><span class='key'>not</span> <span class='nam'>_lock</span><span class='op'>)</span> <span class='key'>and</span> <span class='nam'>thread</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>_lock</span> <span class='op'>=</span> <span class='nam'>threading</span><span class='op'>.</span><span class='nam'>RLock</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm par run hide_run'><span class='annotate' title='no jump to this line number'>exit</span>&nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>_lock</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>_lock</span><span class='op'>.</span><span class='nam'>acquire</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>def</span> <span class='nam'>_releaseLock</span><span class='op'>(</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Release the module-level lock acquired by calling _acquireLock().</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm par run hide_run'><span class='annotate' title='no jump to this line number'>exit</span>&nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>_lock</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>_lock</span><span class='op'>.</span><span class='nam'>release</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#---------------------------------------------------------------------------</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#&nbsp;&nbsp; The logging record</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#---------------------------------------------------------------------------</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>class</span> <span class='nam'>LogRecord</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; A LogRecord instance represents an event being logged.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; LogRecord instances are created every time something is logged. They</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; contain all the information pertinent to the event being logged. The</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; main information passed in is in msg and args, which are combined</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; using str(msg) % args to create the message field of the record. The</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; record also includes information such as when the record was created,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; the source line where the logging call was made, and any exception</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; information to be logged.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__init__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>name</span><span class='op'>,</span> <span class='nam'>level</span><span class='op'>,</span> <span class='nam'>pathname</span><span class='op'>,</span> <span class='nam'>lineno</span><span class='op'>,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; <span class='nam'>msg</span><span class='op'>,</span> <span class='nam'>args</span><span class='op'>,</span> <span class='nam'>exc_info</span><span class='op'>,</span> <span class='nam'>func</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Initialize a logging record with interesting information.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>ct</span> <span class='op'>=</span> <span class='nam'>time</span><span class='op'>.</span><span class='nam'>time</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>name</span> <span class='op'>=</span> <span class='nam'>name</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>msg</span> <span class='op'>=</span> <span class='nam'>msg</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='com'>#</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='com'># The following statement allows passing of a dictionary as a sole</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='com'># argument, so that you can do something like</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='com'>#&nbsp; logging.debug(&quot;a %(a)d b %(b)s&quot;, {&#39;a&#39;:1, &#39;b&#39;:2})</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='com'># Suggested by Stefan Behnel.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='com'># Note that without the test for args[0], we get a problem because</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='com'># during formatting, we test to see if the arg is present using</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='com'># &#39;if self.args:&#39;. If the event being logged is e.g. &#39;Value is %d&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='com'># and if the passed arg fails &#39;if self.args:&#39; then no formatting</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='com'># is done. For example, logger.warn(&#39;Value is %d&#39;, 0) would log</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='com'># &#39;Value is %d&#39; instead of &#39;Value is 0&#39;.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='com'># For the use case of passing a dictionary, this should not be a</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='com'># problem.</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>args</span> <span class='key'>and</span> <span class='nam'>len</span><span class='op'>(</span><span class='nam'>args</span><span class='op'>)</span> <span class='op'>==</span> <span class='num'>1</span> <span class='key'>and</span> <span class='op'>(</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>type</span><span class='op'>(</span><span class='nam'>args</span><span class='op'>[</span><span class='num'>0</span><span class='op'>]</span><span class='op'>)</span> <span class='op'>==</span> <span class='nam'>types</span><span class='op'>.</span><span class='nam'>DictType</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; <span class='op'>)</span> <span class='key'>and</span> <span class='nam'>args</span><span class='op'>[</span><span class='num'>0</span><span class='op'>]</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>args</span> <span class='op'>=</span> <span class='nam'>args</span><span class='op'>[</span><span class='num'>0</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>args</span> <span class='op'>=</span> <span class='nam'>args</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>levelname</span> <span class='op'>=</span> <span class='nam'>getLevelName</span><span class='op'>(</span><span class='nam'>level</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>levelno</span> <span class='op'>=</span> <span class='nam'>level</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>pathname</span> <span class='op'>=</span> <span class='nam'>pathname</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>try</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>filename</span> <span class='op'>=</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>.</span><span class='nam'>basename</span><span class='op'>(</span><span class='nam'>pathname</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>module</span> <span class='op'>=</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>.</span><span class='nam'>splitext</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>filename</span><span class='op'>)</span><span class='op'>[</span><span class='num'>0</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>except</span> <span class='op'>(</span><span class='nam'>TypeError</span><span class='op'>,</span> <span class='nam'>ValueError</span><span class='op'>,</span> <span class='nam'>AttributeError</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>filename</span> <span class='op'>=</span> <span class='nam'>pathname</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>module</span> <span class='op'>=</span> <span class='str'>&quot;Unknown module&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>exc_info</span> <span class='op'>=</span> <span class='nam'>exc_info</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>exc_text</span> <span class='op'>=</span> <span class='nam'>None</span>&nbsp; &nbsp; &nbsp; <span class='com'># used to cache the traceback text</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>lineno</span> <span class='op'>=</span> <span class='nam'>lineno</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>funcName</span> <span class='op'>=</span> <span class='nam'>func</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>created</span> <span class='op'>=</span> <span class='nam'>ct</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>msecs</span> <span class='op'>=</span> <span class='op'>(</span><span class='nam'>ct</span> <span class='op'>-</span> <span class='nam'>long</span><span class='op'>(</span><span class='nam'>ct</span><span class='op'>)</span><span class='op'>)</span> <span class='op'>*</span> <span class='num'>1000</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>relativeCreated</span> <span class='op'>=</span> <span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>created</span> <span class='op'>-</span> <span class='nam'>_startTime</span><span class='op'>)</span> <span class='op'>*</span> <span class='num'>1000</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>logThreads</span> <span class='key'>and</span> <span class='nam'>thread</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>thread</span> <span class='op'>=</span> <span class='nam'>thread</span><span class='op'>.</span><span class='nam'>get_ident</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>threadName</span> <span class='op'>=</span> <span class='nam'>threading</span><span class='op'>.</span><span class='nam'>current_thread</span><span class='op'>(</span><span class='op'>)</span><span class='op'>.</span><span class='nam'>name</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>else</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>thread</span> <span class='op'>=</span> <span class='nam'>None</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>threadName</span> <span class='op'>=</span> <span class='nam'>None</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>logMultiprocessing</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>from</span> <span class='nam'>multiprocessing</span> <span class='key'>import</span> <span class='nam'>current_process</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>processName</span> <span class='op'>=</span> <span class='nam'>current_process</span><span class='op'>(</span><span class='op'>)</span><span class='op'>.</span><span class='nam'>name</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>else</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>processName</span> <span class='op'>=</span> <span class='nam'>None</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>logProcesses</span> <span class='key'>and</span> <span class='nam'>hasattr</span><span class='op'>(</span><span class='nam'>os</span><span class='op'>,</span> <span class='str'>&#39;getpid&#39;</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>process</span> <span class='op'>=</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>getpid</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>else</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>process</span> <span class='op'>=</span> <span class='nam'>None</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__str__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='str'>&#39;&lt;LogRecord: %s, %s, %s, %s, &quot;%s&quot;&gt;&#39;</span><span class='op'>%</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>name</span><span class='op'>,</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>levelno</span><span class='op'>,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>pathname</span><span class='op'>,</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>lineno</span><span class='op'>,</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>msg</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>getMessage</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Return the message for this LogRecord.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Return the message for this LogRecord after merging any user-supplied</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; arguments with the message.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='key'>not</span> <span class='nam'>hasattr</span><span class='op'>(</span><span class='nam'>types</span><span class='op'>,</span> <span class='str'>&quot;UnicodeType&quot;</span><span class='op'>)</span><span class='op'>:</span> <span class='com'>#if no unicode support...</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>msg</span> <span class='op'>=</span> <span class='nam'>str</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>msg</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>else</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>msg</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>msg</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>type</span><span class='op'>(</span><span class='nam'>msg</span><span class='op'>)</span> <span class='key'>not</span> <span class='key'>in</span> <span class='op'>(</span><span class='nam'>types</span><span class='op'>.</span><span class='nam'>UnicodeType</span><span class='op'>,</span> <span class='nam'>types</span><span class='op'>.</span><span class='nam'>StringType</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>try</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>msg</span> <span class='op'>=</span> <span class='nam'>str</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>msg</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>except</span> <span class='nam'>UnicodeError</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>msg</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>msg</span>&nbsp; &nbsp; &nbsp; <span class='com'>#Defer encoding till later</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>args</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>msg</span> <span class='op'>=</span> <span class='nam'>msg</span> <span class='op'>%</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>args</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>msg</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>def</span> <span class='nam'>makeLogRecord</span><span class='op'>(</span><span class='nam'>dict</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Make a LogRecord whose attributes are defined by the specified dictionary,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; This function is useful for converting a logging event received over</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; a socket connection (which is sent as a dictionary) into a LogRecord</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; instance.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='nam'>rv</span> <span class='op'>=</span> <span class='nam'>LogRecord</span><span class='op'>(</span><span class='nam'>None</span><span class='op'>,</span> <span class='nam'>None</span><span class='op'>,</span> <span class='str'>&quot;&quot;</span><span class='op'>,</span> <span class='num'>0</span><span class='op'>,</span> <span class='str'>&quot;&quot;</span><span class='op'>,</span> <span class='op'>(</span><span class='op'>)</span><span class='op'>,</span> <span class='nam'>None</span><span class='op'>,</span> <span class='nam'>None</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='nam'>rv</span><span class='op'>.</span><span class='nam'>__dict__</span><span class='op'>.</span><span class='nam'>update</span><span class='op'>(</span><span class='nam'>dict</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>rv</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#---------------------------------------------------------------------------</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#&nbsp;&nbsp; Formatter classes and functions</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#---------------------------------------------------------------------------</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>class</span> <span class='nam'>Formatter</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Formatter instances are used to convert a LogRecord to text.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Formatters need to know how a LogRecord is constructed. They are</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; responsible for converting a LogRecord to (usually) a string which can</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; be interpreted by either a human or an external system. The base Formatter</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; allows a formatting string to be specified. If none is supplied, the</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; default value of &quot;%s(message)\\n&quot; is used.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; The Formatter can be initialized with a format string which makes use of</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; knowledge of the LogRecord attributes - e.g. the default value mentioned</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; above makes use of the fact that the user&#39;s message and arguments are pre-</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; formatted into a LogRecord&#39;s message attribute. Currently, the useful</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; attributes in a LogRecord are described by:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; %(name)s&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Name of the logger (logging channel)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; %(levelno)s&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; Numeric logging level for the message (DEBUG, INFO,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; WARNING, ERROR, CRITICAL)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; %(levelname)s&nbsp; &nbsp; &nbsp;&nbsp; Text logging level for the message (&quot;DEBUG&quot;, &quot;INFO&quot;,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;WARNING&quot;, &quot;ERROR&quot;, &quot;CRITICAL&quot;)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; %(pathname)s&nbsp; &nbsp; &nbsp; &nbsp; Full pathname of the source file where the logging</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; call was issued (if available)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; %(filename)s&nbsp; &nbsp; &nbsp; &nbsp; Filename portion of pathname</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; %(module)s&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Module (name portion of filename)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; %(lineno)d&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Source line number where the logging call was issued</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (if available)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; %(funcName)s&nbsp; &nbsp; &nbsp; &nbsp; Function name</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; %(created)f&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; Time when the LogRecord was created (time.time()</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return value)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; %(asctime)s&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; Textual time when the LogRecord was created</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; %(msecs)d&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; Millisecond portion of the creation time</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; %(relativeCreated)d Time in milliseconds when the LogRecord was created,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; relative to the time the logging module was loaded</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (typically at application startup time)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; %(thread)d&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Thread ID (if available)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; %(threadName)s&nbsp; &nbsp; &nbsp; Thread name (if available)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; %(process)d&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; Process ID (if available)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; %(message)s&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; The result of record.getMessage(), computed just as</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; the record is emitted</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='nam'>converter</span> <span class='op'>=</span> <span class='nam'>time</span><span class='op'>.</span><span class='nam'>localtime</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__init__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>fmt</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>,</span> <span class='nam'>datefmt</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Initialize the formatter with specified format strings.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Initialize the formatter either with the specified format string, or a</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; default as described above. Allow for specialized date formatting with</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; the optional datefmt argument (if omitted, you get the ISO8601 format).</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>fmt</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_fmt</span> <span class='op'>=</span> <span class='nam'>fmt</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>else</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_fmt</span> <span class='op'>=</span> <span class='str'>&quot;%(message)s&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>datefmt</span> <span class='op'>=</span> <span class='nam'>datefmt</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>formatTime</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>record</span><span class='op'>,</span> <span class='nam'>datefmt</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Return the creation time of the specified LogRecord as formatted text.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; This method should be called from format() by a formatter which</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; wants to make use of a formatted time. This method can be overridden</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; in formatters to provide for any specific requirement, but the</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; basic behaviour is as follows: if datefmt (a string) is specified,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; it is used with time.strftime() to format the creation time of the</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; record. Otherwise, the ISO8601 format is used. The resulting</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; string is returned. This function uses a user-configurable function</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; to convert the creation time to a tuple. By default, time.localtime()</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; is used; to change this for a particular formatter instance, set the</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &#39;converter&#39; attribute to a function with the same signature as</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; time.localtime() or time.gmtime(). To change it for all formatters,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; for example if you want all logging times to be shown in GMT,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; set the &#39;converter&#39; attribute in the Formatter class.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>ct</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>converter</span><span class='op'>(</span><span class='nam'>record</span><span class='op'>.</span><span class='nam'>created</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>datefmt</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>s</span> <span class='op'>=</span> <span class='nam'>time</span><span class='op'>.</span><span class='nam'>strftime</span><span class='op'>(</span><span class='nam'>datefmt</span><span class='op'>,</span> <span class='nam'>ct</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>else</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>t</span> <span class='op'>=</span> <span class='nam'>time</span><span class='op'>.</span><span class='nam'>strftime</span><span class='op'>(</span><span class='str'>&quot;%Y-%m-%d %H:%M:%S&quot;</span><span class='op'>,</span> <span class='nam'>ct</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>s</span> <span class='op'>=</span> <span class='str'>&quot;%s,%03d&quot;</span> <span class='op'>%</span> <span class='op'>(</span><span class='nam'>t</span><span class='op'>,</span> <span class='nam'>record</span><span class='op'>.</span><span class='nam'>msecs</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>s</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>formatException</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>ei</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Format and return the specified exception information as a string.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; This default implementation just uses</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; traceback.print_exception()</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>sio</span> <span class='op'>=</span> <span class='nam'>cStringIO</span><span class='op'>.</span><span class='nam'>StringIO</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>traceback</span><span class='op'>.</span><span class='nam'>print_exception</span><span class='op'>(</span><span class='nam'>ei</span><span class='op'>[</span><span class='num'>0</span><span class='op'>]</span><span class='op'>,</span> <span class='nam'>ei</span><span class='op'>[</span><span class='num'>1</span><span class='op'>]</span><span class='op'>,</span> <span class='nam'>ei</span><span class='op'>[</span><span class='num'>2</span><span class='op'>]</span><span class='op'>,</span> <span class='nam'>None</span><span class='op'>,</span> <span class='nam'>sio</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>s</span> <span class='op'>=</span> <span class='nam'>sio</span><span class='op'>.</span><span class='nam'>getvalue</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>sio</span><span class='op'>.</span><span class='nam'>close</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>s</span><span class='op'>[</span><span class='op'>-</span><span class='num'>1</span><span class='op'>:</span><span class='op'>]</span> <span class='op'>==</span> <span class='str'>&quot;\n&quot;</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>s</span> <span class='op'>=</span> <span class='nam'>s</span><span class='op'>[</span><span class='op'>:</span><span class='op'>-</span><span class='num'>1</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>s</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>format</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>record</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Format the specified record as text.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; The record&#39;s attribute dictionary is used as the operand to a</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; string formatting operation which yields the returned string.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Before formatting the dictionary, a couple of preparatory steps</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; are carried out. The message attribute of the record is computed</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; using LogRecord.getMessage(). If the formatting string contains</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;%(asctime)&quot;, formatTime() is called to format the event time.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; If there is exception information, it is formatted using</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; formatException() and appended to the message.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>record</span><span class='op'>.</span><span class='nam'>message</span> <span class='op'>=</span> <span class='nam'>record</span><span class='op'>.</span><span class='nam'>getMessage</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>string</span><span class='op'>.</span><span class='nam'>find</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>_fmt</span><span class='op'>,</span><span class='str'>&quot;%(asctime)&quot;</span><span class='op'>)</span> <span class='op'>&gt;=</span> <span class='num'>0</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>record</span><span class='op'>.</span><span class='nam'>asctime</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>formatTime</span><span class='op'>(</span><span class='nam'>record</span><span class='op'>,</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>datefmt</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>s</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_fmt</span> <span class='op'>%</span> <span class='nam'>record</span><span class='op'>.</span><span class='nam'>__dict__</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>record</span><span class='op'>.</span><span class='nam'>exc_info</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='com'># Cache the traceback text to avoid converting it multiple times</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='com'># (it&#39;s constant anyway)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='key'>not</span> <span class='nam'>record</span><span class='op'>.</span><span class='nam'>exc_text</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>record</span><span class='op'>.</span><span class='nam'>exc_text</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>formatException</span><span class='op'>(</span><span class='nam'>record</span><span class='op'>.</span><span class='nam'>exc_info</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>record</span><span class='op'>.</span><span class='nam'>exc_text</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>s</span><span class='op'>[</span><span class='op'>-</span><span class='num'>1</span><span class='op'>:</span><span class='op'>]</span> <span class='op'>!=</span> <span class='str'>&quot;\n&quot;</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>s</span> <span class='op'>=</span> <span class='nam'>s</span> <span class='op'>+</span> <span class='str'>&quot;\n&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>s</span> <span class='op'>=</span> <span class='nam'>s</span> <span class='op'>+</span> <span class='nam'>record</span><span class='op'>.</span><span class='nam'>exc_text</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>s</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#&nbsp;&nbsp; The default formatter to use when no other is specified</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='nam'>_defaultFormatter</span> <span class='op'>=</span> <span class='nam'>Formatter</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>class</span> <span class='nam'>BufferingFormatter</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; A formatter suitable for formatting a number of records.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__init__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>linefmt</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Optionally specify a formatter which will be used to format each</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; individual record.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>linefmt</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>linefmt</span> <span class='op'>=</span> <span class='nam'>linefmt</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>else</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>linefmt</span> <span class='op'>=</span> <span class='nam'>_defaultFormatter</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>formatHeader</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>records</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Return the header string for the specified records.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='str'>&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>formatFooter</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>records</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Return the footer string for the specified records.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='str'>&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>format</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>records</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Format the specified records and return the result as a string.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>rv</span> <span class='op'>=</span> <span class='str'>&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>len</span><span class='op'>(</span><span class='nam'>records</span><span class='op'>)</span> <span class='op'>&gt;</span> <span class='num'>0</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>rv</span> <span class='op'>=</span> <span class='nam'>rv</span> <span class='op'>+</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>formatHeader</span><span class='op'>(</span><span class='nam'>records</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>for</span> <span class='nam'>record</span> <span class='key'>in</span> <span class='nam'>records</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>rv</span> <span class='op'>=</span> <span class='nam'>rv</span> <span class='op'>+</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>linefmt</span><span class='op'>.</span><span class='nam'>format</span><span class='op'>(</span><span class='nam'>record</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>rv</span> <span class='op'>=</span> <span class='nam'>rv</span> <span class='op'>+</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>formatFooter</span><span class='op'>(</span><span class='nam'>records</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>rv</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#---------------------------------------------------------------------------</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#&nbsp;&nbsp; Filter classes and functions</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#---------------------------------------------------------------------------</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>class</span> <span class='nam'>Filter</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Filter instances are used to perform arbitrary filtering of LogRecords.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Loggers and Handlers can optionally use Filter instances to filter</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; records as desired. The base filter class only allows events which are</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; below a certain point in the logger hierarchy. For example, a filter</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; initialized with &quot;A.B&quot; will allow events logged by loggers &quot;A.B&quot;,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;A.B.C&quot;, &quot;A.B.C.D&quot;, &quot;A.B.D&quot; etc. but not &quot;A.BB&quot;, &quot;B.A.B&quot; etc. If</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; initialized with the empty string, all events are passed.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__init__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>name</span><span class='op'>=</span><span class='str'>&#39;&#39;</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Initialize a filter.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Initialize with the name of the logger which, together with its</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; children, will have its events allowed through the filter. If no</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; name is specified, allow every event.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>name</span> <span class='op'>=</span> <span class='nam'>name</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>nlen</span> <span class='op'>=</span> <span class='nam'>len</span><span class='op'>(</span><span class='nam'>name</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>filter</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>record</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Determine if the specified record is to be logged.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Is the specified record to be logged? Returns 0 for no, nonzero for</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; yes. If deemed appropriate, the record may be modified in-place.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>nlen</span> <span class='op'>==</span> <span class='num'>0</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='num'>1</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>elif</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>name</span> <span class='op'>==</span> <span class='nam'>record</span><span class='op'>.</span><span class='nam'>name</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='num'>1</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>elif</span> <span class='nam'>string</span><span class='op'>.</span><span class='nam'>find</span><span class='op'>(</span><span class='nam'>record</span><span class='op'>.</span><span class='nam'>name</span><span class='op'>,</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>name</span><span class='op'>,</span> <span class='num'>0</span><span class='op'>,</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>nlen</span><span class='op'>)</span> <span class='op'>!=</span> <span class='num'>0</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='num'>0</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='op'>(</span><span class='nam'>record</span><span class='op'>.</span><span class='nam'>name</span><span class='op'>[</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>nlen</span><span class='op'>]</span> <span class='op'>==</span> <span class='str'>&quot;.&quot;</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>class</span> <span class='nam'>Filterer</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; A base class for loggers and handlers which allows them to share</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; common code.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__init__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Initialize the list of filters to be an empty list.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>filters</span> <span class='op'>=</span> <span class='op'>[</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>addFilter</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>filter</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Add the specified filter to this handler.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='key'>not</span> <span class='op'>(</span><span class='nam'>filter</span> <span class='key'>in</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>filters</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>filters</span><span class='op'>.</span><span class='nam'>append</span><span class='op'>(</span><span class='nam'>filter</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>removeFilter</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>filter</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Remove the specified filter from this handler.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>filter</span> <span class='key'>in</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>filters</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>filters</span><span class='op'>.</span><span class='nam'>remove</span><span class='op'>(</span><span class='nam'>filter</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>filter</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>record</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Determine if a record is loggable by consulting all the filters.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; The default is to allow the record to be logged; any filter can veto</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; this and the record is then dropped. Returns a zero value if a record</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; is to be dropped, else non-zero.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>rv</span> <span class='op'>=</span> <span class='num'>1</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>for</span> <span class='nam'>f</span> <span class='key'>in</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>filters</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='key'>not</span> <span class='nam'>f</span><span class='op'>.</span><span class='nam'>filter</span><span class='op'>(</span><span class='nam'>record</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>rv</span> <span class='op'>=</span> <span class='num'>0</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>break</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>rv</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#---------------------------------------------------------------------------</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#&nbsp;&nbsp; Handler classes and functions</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#---------------------------------------------------------------------------</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='nam'>_handlers</span> <span class='op'>=</span> <span class='op'>{</span><span class='op'>}</span>&nbsp; <span class='com'>#repository of handlers (for flushing when shutdown called)</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='nam'>_handlerList</span> <span class='op'>=</span> <span class='op'>[</span><span class='op'>]</span> <span class='com'># added to allow handlers to be removed in reverse of order initialized</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>class</span> <span class='nam'>Handler</span><span class='op'>(</span><span class='nam'>Filterer</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Handler instances dispatch logging events to specific destinations.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; The base handler class. Acts as a placeholder which defines the Handler</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; interface. Handlers can optionally use Formatter instances to format</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; records as desired. By default, no formatter is specified; in this case,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; the &#39;raw&#39; message as determined by record.message is logged.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__init__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>level</span><span class='op'>=</span><span class='nam'>NOTSET</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Initializes the instance - basically setting the formatter to None</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; and the filter list to empty.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>Filterer</span><span class='op'>.</span><span class='nam'>__init__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>level</span> <span class='op'>=</span> <span class='nam'>level</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>formatter</span> <span class='op'>=</span> <span class='nam'>None</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='com'>#get the module data lock, as we&#39;re updating a shared structure.</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>_acquireLock</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>try</span><span class='op'>:</span>&nbsp; &nbsp; <span class='com'>#unlikely to raise an exception, but you never know...</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>_handlers</span><span class='op'>[</span><span class='nam'>self</span><span class='op'>]</span> <span class='op'>=</span> <span class='num'>1</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>_handlerList</span><span class='op'>.</span><span class='nam'>insert</span><span class='op'>(</span><span class='num'>0</span><span class='op'>,</span> <span class='nam'>self</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>finally</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>_releaseLock</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>createLock</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>createLock</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Acquire a thread lock for serializing access to the underlying I/O.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm par run hide_run'><span class='annotate' title='no jump to this line number'>611</span>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>thread</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>lock</span> <span class='op'>=</span> <span class='nam'>threading</span><span class='op'>.</span><span class='nam'>RLock</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>else</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>lock</span> <span class='op'>=</span> <span class='nam'>None</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>acquire</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Acquire the I/O thread lock.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>lock</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>lock</span><span class='op'>.</span><span class='nam'>acquire</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>release</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Release the I/O thread lock.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>lock</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>lock</span><span class='op'>.</span><span class='nam'>release</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>setLevel</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>level</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Set the logging level of this handler.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>level</span> <span class='op'>=</span> <span class='nam'>level</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>format</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>record</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Format the specified record.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; If a formatter is set, use it. Otherwise, use the default formatter</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; for the module.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>formatter</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>fmt</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>formatter</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>else</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>fmt</span> <span class='op'>=</span> <span class='nam'>_defaultFormatter</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>fmt</span><span class='op'>.</span><span class='nam'>format</span><span class='op'>(</span><span class='nam'>record</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>emit</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>record</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Do whatever it takes to actually log the specified logging record.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; This version is intended to be implemented by subclasses and so</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; raises a NotImplementedError.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>raise</span> <span class='nam'>NotImplementedError</span><span class='op'>,</span> <span class='str'>&#39;emit must be implemented &#39;</span><span class='xx'>\</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&#39;by Handler subclasses&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>handle</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>record</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Conditionally emit the specified logging record.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Emission depends on filters which may have been added to the handler.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Wrap the actual emission of the record with acquisition/release of</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; the I/O thread lock. Returns whether the filter passed the record for</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; emission.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>rv</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>filter</span><span class='op'>(</span><span class='nam'>record</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>rv</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>acquire</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>try</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>emit</span><span class='op'>(</span><span class='nam'>record</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>finally</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>release</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>rv</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>setFormatter</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>fmt</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Set the formatter for this handler.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>formatter</span> <span class='op'>=</span> <span class='nam'>fmt</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>flush</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Ensure all logging output has been flushed.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; This version does nothing and is intended to be implemented by</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; subclasses.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>pass</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>close</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Tidy up any resources used by the handler.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; This version does removes the handler from an internal list</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; of handlers which is closed when shutdown() is called. Subclasses</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; should ensure that this gets called from overridden close()</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; methods.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='com'>#get the module data lock, as we&#39;re updating a shared structure.</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>_acquireLock</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>try</span><span class='op'>:</span>&nbsp; &nbsp; <span class='com'>#unlikely to raise an exception, but you never know...</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>del</span> <span class='nam'>_handlers</span><span class='op'>[</span><span class='nam'>self</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>_handlerList</span><span class='op'>.</span><span class='nam'>remove</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>finally</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>_releaseLock</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>handleError</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>record</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Handle errors which occur during an emit() call.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; This method should be called from handlers when an exception is</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; encountered during an emit() call. If raiseExceptions is false,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; exceptions get silently ignored. This is what is mostly wanted</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; for a logging system - most users will not care about errors in</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; the logging system, they are more interested in application errors.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; You could, however, replace this with a custom handler if you wish.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; The record which was being processed is passed in to this method.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>raiseExceptions</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>ei</span> <span class='op'>=</span> <span class='nam'>sys</span><span class='op'>.</span><span class='nam'>exc_info</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>traceback</span><span class='op'>.</span><span class='nam'>print_exception</span><span class='op'>(</span><span class='nam'>ei</span><span class='op'>[</span><span class='num'>0</span><span class='op'>]</span><span class='op'>,</span> <span class='nam'>ei</span><span class='op'>[</span><span class='num'>1</span><span class='op'>]</span><span class='op'>,</span> <span class='nam'>ei</span><span class='op'>[</span><span class='num'>2</span><span class='op'>]</span><span class='op'>,</span> <span class='nam'>None</span><span class='op'>,</span> <span class='nam'>sys</span><span class='op'>.</span><span class='nam'>stderr</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>del</span> <span class='nam'>ei</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>class</span> <span class='nam'>StreamHandler</span><span class='op'>(</span><span class='nam'>Handler</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; A handler class which writes logging records, appropriately formatted,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; to a stream. Note that this class does not close the stream, as</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; sys.stdout or sys.stderr may be used.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__init__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>strm</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Initialize the handler.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; If strm is not specified, sys.stderr is used.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>Handler</span><span class='op'>.</span><span class='nam'>__init__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>strm</span> <span class='key'>is</span> <span class='nam'>None</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>strm</span> <span class='op'>=</span> <span class='nam'>sys</span><span class='op'>.</span><span class='nam'>stderr</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>stream</span> <span class='op'>=</span> <span class='nam'>strm</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>flush</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Flushes the stream.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>stream</span> <span class='key'>and</span> <span class='nam'>hasattr</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>stream</span><span class='op'>,</span> <span class='str'>&quot;flush&quot;</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>stream</span><span class='op'>.</span><span class='nam'>flush</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>emit</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>record</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Emit a record.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; If a formatter is specified, it is used to format the record.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; The record is then written to the stream with a trailing newline.&nbsp; If</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; exception information is present, it is formatted using</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; traceback.print_exception and appended to the stream.&nbsp; If the stream</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; has an &#39;encoding&#39; attribute, it is used to encode the message before</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; output to the stream.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>try</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>msg</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>format</span><span class='op'>(</span><span class='nam'>record</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>stream</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>stream</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>fs</span> <span class='op'>=</span> <span class='str'>&quot;%s\n&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='key'>not</span> <span class='nam'>hasattr</span><span class='op'>(</span><span class='nam'>types</span><span class='op'>,</span> <span class='str'>&quot;UnicodeType&quot;</span><span class='op'>)</span><span class='op'>:</span> <span class='com'>#if no unicode support...</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>stream</span><span class='op'>.</span><span class='nam'>write</span><span class='op'>(</span><span class='nam'>fs</span> <span class='op'>%</span> <span class='nam'>msg</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>else</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>try</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='op'>(</span><span class='nam'>isinstance</span><span class='op'>(</span><span class='nam'>msg</span><span class='op'>,</span> <span class='nam'>unicode</span><span class='op'>)</span> <span class='key'>or</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>getattr</span><span class='op'>(</span><span class='nam'>stream</span><span class='op'>,</span> <span class='str'>&#39;encoding&#39;</span><span class='op'>,</span> <span class='nam'>None</span><span class='op'>)</span> <span class='key'>is</span> <span class='nam'>None</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>stream</span><span class='op'>.</span><span class='nam'>write</span><span class='op'>(</span><span class='nam'>fs</span> <span class='op'>%</span> <span class='nam'>msg</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>else</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>stream</span><span class='op'>.</span><span class='nam'>write</span><span class='op'>(</span><span class='nam'>fs</span> <span class='op'>%</span> <span class='nam'>msg</span><span class='op'>.</span><span class='nam'>encode</span><span class='op'>(</span><span class='nam'>stream</span><span class='op'>.</span><span class='nam'>encoding</span><span class='op'>)</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>except</span> <span class='nam'>UnicodeError</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>stream</span><span class='op'>.</span><span class='nam'>write</span><span class='op'>(</span><span class='nam'>fs</span> <span class='op'>%</span> <span class='nam'>msg</span><span class='op'>.</span><span class='nam'>encode</span><span class='op'>(</span><span class='str'>&quot;UTF-8&quot;</span><span class='op'>)</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>flush</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>except</span> <span class='op'>(</span><span class='nam'>KeyboardInterrupt</span><span class='op'>,</span> <span class='nam'>SystemExit</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>raise</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>except</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>handleError</span><span class='op'>(</span><span class='nam'>record</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>class</span> <span class='nam'>FileHandler</span><span class='op'>(</span><span class='nam'>StreamHandler</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; A handler class which writes formatted logging records to disk files.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__init__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>filename</span><span class='op'>,</span> <span class='nam'>mode</span><span class='op'>=</span><span class='str'>&#39;a&#39;</span><span class='op'>,</span> <span class='nam'>encoding</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>,</span> <span class='nam'>delay</span><span class='op'>=</span><span class='num'>0</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Open the specified file and use it as the stream for logging.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='com'>#keep the absolute path, otherwise derived classes which use this</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='com'>#may come a cropper when the current directory changes</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>codecs</span> <span class='key'>is</span> <span class='nam'>None</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>encoding</span> <span class='op'>=</span> <span class='nam'>None</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>baseFilename</span> <span class='op'>=</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>.</span><span class='nam'>abspath</span><span class='op'>(</span><span class='nam'>filename</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>mode</span> <span class='op'>=</span> <span class='nam'>mode</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>encoding</span> <span class='op'>=</span> <span class='nam'>encoding</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>delay</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='com'>#We don&#39;t open the stream, but we still need to call the</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='com'>#Handler constructor to set level, formatter, lock etc.</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>Handler</span><span class='op'>.</span><span class='nam'>__init__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>stream</span> <span class='op'>=</span> <span class='nam'>None</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>else</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>StreamHandler</span><span class='op'>.</span><span class='nam'>__init__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_open</span><span class='op'>(</span><span class='op'>)</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>close</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Closes the stream.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>stream</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>flush</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>hasattr</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>stream</span><span class='op'>,</span> <span class='str'>&quot;close&quot;</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>stream</span><span class='op'>.</span><span class='nam'>close</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>StreamHandler</span><span class='op'>.</span><span class='nam'>close</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>stream</span> <span class='op'>=</span> <span class='nam'>None</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>_open</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Open the current base file with the (original) mode and encoding.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Return the resulting stream.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>encoding</span> <span class='key'>is</span> <span class='nam'>None</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>stream</span> <span class='op'>=</span> <span class='nam'>open</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>baseFilename</span><span class='op'>,</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>mode</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>else</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>stream</span> <span class='op'>=</span> <span class='nam'>codecs</span><span class='op'>.</span><span class='nam'>open</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>baseFilename</span><span class='op'>,</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>mode</span><span class='op'>,</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>encoding</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>stream</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>emit</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>record</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Emit a record.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; If the stream was not opened because &#39;delay&#39; was specified in the</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; constructor, open it before calling the superclass&#39;s emit.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>stream</span> <span class='key'>is</span> <span class='nam'>None</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>stream</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_open</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>StreamHandler</span><span class='op'>.</span><span class='nam'>emit</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>record</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#---------------------------------------------------------------------------</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#&nbsp;&nbsp; Manager classes and functions</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#---------------------------------------------------------------------------</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>class</span> <span class='nam'>PlaceHolder</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; PlaceHolder instances are used in the Manager logger hierarchy to take</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; the place of nodes for which no loggers have been defined. This class is</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; intended for internal use only and not as part of the public API.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__init__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>alogger</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Initialize with the specified logger being a child of this placeholder.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='com'>#self.loggers = [alogger]</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>loggerMap</span> <span class='op'>=</span> <span class='op'>{</span> <span class='nam'>alogger</span> <span class='op'>:</span> <span class='nam'>None</span> <span class='op'>}</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>append</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>alogger</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Add the specified logger as a child of this placeholder.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='com'>#if alogger not in self.loggers:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>alogger</span> <span class='key'>not</span> <span class='key'>in</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>loggerMap</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='com'>#self.loggers.append(alogger)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>loggerMap</span><span class='op'>[</span><span class='nam'>alogger</span><span class='op'>]</span> <span class='op'>=</span> <span class='nam'>None</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#&nbsp;&nbsp; Determine which class to use when instantiating loggers.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='nam'>_loggerClass</span> <span class='op'>=</span> <span class='nam'>None</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>def</span> <span class='nam'>setLoggerClass</span><span class='op'>(</span><span class='nam'>klass</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Set the class to be used when instantiating a logger. The class should</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; define __init__() such that only a name argument is required, and the</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; __init__() should call Logger.__init__()</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>klass</span> <span class='op'>!=</span> <span class='nam'>Logger</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='key'>not</span> <span class='nam'>issubclass</span><span class='op'>(</span><span class='nam'>klass</span><span class='op'>,</span> <span class='nam'>Logger</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>raise</span> <span class='nam'>TypeError</span><span class='op'>,</span> <span class='str'>&quot;logger not derived from logging.Logger: &quot;</span> <span class='op'>+</span> <span class='xx'>\</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>klass</span><span class='op'>.</span><span class='nam'>__name__</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='key'>global</span> <span class='nam'>_loggerClass</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='nam'>_loggerClass</span> <span class='op'>=</span> <span class='nam'>klass</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>def</span> <span class='nam'>getLoggerClass</span><span class='op'>(</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Return the class to be used when instantiating a logger.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>_loggerClass</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>class</span> <span class='nam'>Manager</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; There is [under normal circumstances] just one Manager instance, which</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; holds the hierarchy of loggers.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__init__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>rootnode</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Initialize the manager with the root node of the logger hierarchy.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>root</span> <span class='op'>=</span> <span class='nam'>rootnode</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>disable</span> <span class='op'>=</span> <span class='num'>0</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>emittedNoHandlerWarning</span> <span class='op'>=</span> <span class='num'>0</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>loggerDict</span> <span class='op'>=</span> <span class='op'>{</span><span class='op'>}</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>getLogger</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>name</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Get a logger with the specified name (channel name), creating it</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; if it doesn&#39;t yet exist. This name is a dot-separated hierarchical</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; name, such as &quot;a&quot;, &quot;a.b&quot;, &quot;a.b.c&quot; or similar.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; If a PlaceHolder existed for the specified name [i.e. the logger</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; didn&#39;t exist but a child of it did], replace it with the created</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; logger and fix up the parent/child references which pointed to the</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; placeholder to now point to the logger.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>rv</span> <span class='op'>=</span> <span class='nam'>None</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>_acquireLock</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>try</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>name</span> <span class='key'>in</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>loggerDict</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>rv</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>loggerDict</span><span class='op'>[</span><span class='nam'>name</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='stm par run hide_run'><span class='annotate' title='no jumps to these line numbers'>918&nbsp;&nbsp; 928</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>isinstance</span><span class='op'>(</span><span class='nam'>rv</span><span class='op'>,</span> <span class='nam'>PlaceHolder</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>ph</span> <span class='op'>=</span> <span class='nam'>rv</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>rv</span> <span class='op'>=</span> <span class='nam'>_loggerClass</span><span class='op'>(</span><span class='nam'>name</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>rv</span><span class='op'>.</span><span class='nam'>manager</span> <span class='op'>=</span> <span class='nam'>self</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>loggerDict</span><span class='op'>[</span><span class='nam'>name</span><span class='op'>]</span> <span class='op'>=</span> <span class='nam'>rv</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_fixupChildren</span><span class='op'>(</span><span class='nam'>ph</span><span class='op'>,</span> <span class='nam'>rv</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_fixupParents</span><span class='op'>(</span><span class='nam'>rv</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>else</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>rv</span> <span class='op'>=</span> <span class='nam'>_loggerClass</span><span class='op'>(</span><span class='nam'>name</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>rv</span><span class='op'>.</span><span class='nam'>manager</span> <span class='op'>=</span> <span class='nam'>self</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>loggerDict</span><span class='op'>[</span><span class='nam'>name</span><span class='op'>]</span> <span class='op'>=</span> <span class='nam'>rv</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_fixupParents</span><span class='op'>(</span><span class='nam'>rv</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>finally</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>_releaseLock</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>rv</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>_fixupParents</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>alogger</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Ensure that there are either loggers or placeholders all the way</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; from the specified logger to the root of the logger hierarchy.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>name</span> <span class='op'>=</span> <span class='nam'>alogger</span><span class='op'>.</span><span class='nam'>name</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>i</span> <span class='op'>=</span> <span class='nam'>string</span><span class='op'>.</span><span class='nam'>rfind</span><span class='op'>(</span><span class='nam'>name</span><span class='op'>,</span> <span class='str'>&quot;.&quot;</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>rv</span> <span class='op'>=</span> <span class='nam'>None</span><span class='strut'>&nbsp;</span></p>
<p class='stm par run hide_run'><span class='annotate' title='no jump to this line number'>942</span>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>while</span> <span class='op'>(</span><span class='nam'>i</span> <span class='op'>&gt;</span> <span class='num'>0</span><span class='op'>)</span> <span class='key'>and</span> <span class='key'>not</span> <span class='nam'>rv</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>substr</span> <span class='op'>=</span> <span class='nam'>name</span><span class='op'>[</span><span class='op'>:</span><span class='nam'>i</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>substr</span> <span class='key'>not</span> <span class='key'>in</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>loggerDict</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>loggerDict</span><span class='op'>[</span><span class='nam'>substr</span><span class='op'>]</span> <span class='op'>=</span> <span class='nam'>PlaceHolder</span><span class='op'>(</span><span class='nam'>alogger</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>else</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>obj</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>loggerDict</span><span class='op'>[</span><span class='nam'>substr</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>isinstance</span><span class='op'>(</span><span class='nam'>obj</span><span class='op'>,</span> <span class='nam'>Logger</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>rv</span> <span class='op'>=</span> <span class='nam'>obj</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>else</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>assert</span> <span class='nam'>isinstance</span><span class='op'>(</span><span class='nam'>obj</span><span class='op'>,</span> <span class='nam'>PlaceHolder</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>obj</span><span class='op'>.</span><span class='nam'>append</span><span class='op'>(</span><span class='nam'>alogger</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>i</span> <span class='op'>=</span> <span class='nam'>string</span><span class='op'>.</span><span class='nam'>rfind</span><span class='op'>(</span><span class='nam'>name</span><span class='op'>,</span> <span class='str'>&quot;.&quot;</span><span class='op'>,</span> <span class='num'>0</span><span class='op'>,</span> <span class='nam'>i</span> <span class='op'>-</span> <span class='num'>1</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm par run hide_run'><span class='annotate' title='no jump to this line number'>955</span>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='key'>not</span> <span class='nam'>rv</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>rv</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>root</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>alogger</span><span class='op'>.</span><span class='nam'>parent</span> <span class='op'>=</span> <span class='nam'>rv</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>_fixupChildren</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>ph</span><span class='op'>,</span> <span class='nam'>alogger</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Ensure that children of the placeholder ph are connected to the</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; specified logger.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>name</span> <span class='op'>=</span> <span class='nam'>alogger</span><span class='op'>.</span><span class='nam'>name</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>namelen</span> <span class='op'>=</span> <span class='nam'>len</span><span class='op'>(</span><span class='nam'>name</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>for</span> <span class='nam'>c</span> <span class='key'>in</span> <span class='nam'>ph</span><span class='op'>.</span><span class='nam'>loggerMap</span><span class='op'>.</span><span class='nam'>keys</span><span class='op'>(</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='com'>#The if means ... if not c.parent.name.startswith(nm)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='com'>#if string.find(c.parent.name, nm) &lt;&gt; 0:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>c</span><span class='op'>.</span><span class='nam'>parent</span><span class='op'>.</span><span class='nam'>name</span><span class='op'>[</span><span class='op'>:</span><span class='nam'>namelen</span><span class='op'>]</span> <span class='op'>!=</span> <span class='nam'>name</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>alogger</span><span class='op'>.</span><span class='nam'>parent</span> <span class='op'>=</span> <span class='nam'>c</span><span class='op'>.</span><span class='nam'>parent</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>c</span><span class='op'>.</span><span class='nam'>parent</span> <span class='op'>=</span> <span class='nam'>alogger</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#---------------------------------------------------------------------------</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#&nbsp;&nbsp; Logger classes and functions</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#---------------------------------------------------------------------------</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>class</span> <span class='nam'>Logger</span><span class='op'>(</span><span class='nam'>Filterer</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Instances of the Logger class represent a single logging channel. A</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;logging channel&quot; indicates an area of an application. Exactly how an</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;area&quot; is defined is up to the application developer. Since an</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; application can have any number of areas, logging channels are identified</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; by a unique string. Application areas can be nested (e.g. an area</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; of &quot;input processing&quot; might include sub-areas &quot;read CSV files&quot;, &quot;read</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; XLS files&quot; and &quot;read Gnumeric files&quot;). To cater for this natural nesting,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; channel names are organized into a namespace hierarchy where levels are</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; separated by periods, much like the Java or Python package namespace. So</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; in the instance given above, channel names might be &quot;input&quot; for the upper</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; level, and &quot;input.csv&quot;, &quot;input.xls&quot; and &quot;input.gnu&quot; for the sub-levels.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; There is no arbitrary limit to the depth of nesting.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__init__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>name</span><span class='op'>,</span> <span class='nam'>level</span><span class='op'>=</span><span class='nam'>NOTSET</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Initialize the logger with a name and an optional level.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>Filterer</span><span class='op'>.</span><span class='nam'>__init__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>name</span> <span class='op'>=</span> <span class='nam'>name</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>level</span> <span class='op'>=</span> <span class='nam'>level</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>parent</span> <span class='op'>=</span> <span class='nam'>None</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>propagate</span> <span class='op'>=</span> <span class='num'>1</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>handlers</span> <span class='op'>=</span> <span class='op'>[</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>disabled</span> <span class='op'>=</span> <span class='num'>0</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>setLevel</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>level</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Set the logging level of this logger.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>level</span> <span class='op'>=</span> <span class='nam'>level</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>debug</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>msg</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Log &#39;msg % args&#39; with severity &#39;DEBUG&#39;.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; To pass exception information, use the keyword argument exc_info with</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; a true value, e.g.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; logger.debug(&quot;Houston, we have a %s&quot;, &quot;thorny problem&quot;, exc_info=1)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>isEnabledFor</span><span class='op'>(</span><span class='nam'>DEBUG</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_log</span><span class='op'>(</span><span class='nam'>DEBUG</span><span class='op'>,</span> <span class='nam'>msg</span><span class='op'>,</span> <span class='nam'>args</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>info</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>msg</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Log &#39;msg % args&#39; with severity &#39;INFO&#39;.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; To pass exception information, use the keyword argument exc_info with</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; a true value, e.g.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; logger.info(&quot;Houston, we have a %s&quot;, &quot;interesting problem&quot;, exc_info=1)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>isEnabledFor</span><span class='op'>(</span><span class='nam'>INFO</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_log</span><span class='op'>(</span><span class='nam'>INFO</span><span class='op'>,</span> <span class='nam'>msg</span><span class='op'>,</span> <span class='nam'>args</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>warning</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>msg</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Log &#39;msg % args&#39; with severity &#39;WARNING&#39;.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; To pass exception information, use the keyword argument exc_info with</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; a true value, e.g.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; logger.warning(&quot;Houston, we have a %s&quot;, &quot;bit of a problem&quot;, exc_info=1)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>isEnabledFor</span><span class='op'>(</span><span class='nam'>WARNING</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_log</span><span class='op'>(</span><span class='nam'>WARNING</span><span class='op'>,</span> <span class='nam'>msg</span><span class='op'>,</span> <span class='nam'>args</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='nam'>warn</span> <span class='op'>=</span> <span class='nam'>warning</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>error</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>msg</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Log &#39;msg % args&#39; with severity &#39;ERROR&#39;.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; To pass exception information, use the keyword argument exc_info with</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; a true value, e.g.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; logger.error(&quot;Houston, we have a %s&quot;, &quot;major problem&quot;, exc_info=1)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>isEnabledFor</span><span class='op'>(</span><span class='nam'>ERROR</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_log</span><span class='op'>(</span><span class='nam'>ERROR</span><span class='op'>,</span> <span class='nam'>msg</span><span class='op'>,</span> <span class='nam'>args</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>exception</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>msg</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Convenience method for logging an ERROR with exception information.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>error</span><span class='op'>(</span><span class='op'>*</span><span class='op'>(</span><span class='op'>(</span><span class='nam'>msg</span><span class='op'>,</span><span class='op'>)</span> <span class='op'>+</span> <span class='nam'>args</span><span class='op'>)</span><span class='op'>,</span> <span class='op'>**</span><span class='op'>{</span><span class='str'>&#39;exc_info&#39;</span><span class='op'>:</span> <span class='num'>1</span><span class='op'>}</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>critical</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>msg</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Log &#39;msg % args&#39; with severity &#39;CRITICAL&#39;.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; To pass exception information, use the keyword argument exc_info with</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; a true value, e.g.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; logger.critical(&quot;Houston, we have a %s&quot;, &quot;major disaster&quot;, exc_info=1)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>isEnabledFor</span><span class='op'>(</span><span class='nam'>CRITICAL</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_log</span><span class='op'>(</span><span class='nam'>CRITICAL</span><span class='op'>,</span> <span class='nam'>msg</span><span class='op'>,</span> <span class='nam'>args</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='nam'>fatal</span> <span class='op'>=</span> <span class='nam'>critical</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>log</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>level</span><span class='op'>,</span> <span class='nam'>msg</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Log &#39;msg % args&#39; with the integer severity &#39;level&#39;.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; To pass exception information, use the keyword argument exc_info with</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; a true value, e.g.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; logger.log(level, &quot;We have a %s&quot;, &quot;mysterious problem&quot;, exc_info=1)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>type</span><span class='op'>(</span><span class='nam'>level</span><span class='op'>)</span> <span class='op'>!=</span> <span class='nam'>types</span><span class='op'>.</span><span class='nam'>IntType</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>raiseExceptions</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>raise</span> <span class='nam'>TypeError</span><span class='op'>,</span> <span class='str'>&quot;level must be an integer&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>else</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>isEnabledFor</span><span class='op'>(</span><span class='nam'>level</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_log</span><span class='op'>(</span><span class='nam'>level</span><span class='op'>,</span> <span class='nam'>msg</span><span class='op'>,</span> <span class='nam'>args</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>findCaller</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Find the stack frame of the caller so that we can note the source</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; file name, line number and function name.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>f</span> <span class='op'>=</span> <span class='nam'>currentframe</span><span class='op'>(</span><span class='op'>)</span><span class='op'>.</span><span class='nam'>f_back</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>rv</span> <span class='op'>=</span> <span class='str'>&quot;(unknown file)&quot;</span><span class='op'>,</span> <span class='num'>0</span><span class='op'>,</span> <span class='str'>&quot;(unknown function)&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>while</span> <span class='nam'>hasattr</span><span class='op'>(</span><span class='nam'>f</span><span class='op'>,</span> <span class='str'>&quot;f_code&quot;</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>co</span> <span class='op'>=</span> <span class='nam'>f</span><span class='op'>.</span><span class='nam'>f_code</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>filename</span> <span class='op'>=</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>.</span><span class='nam'>normcase</span><span class='op'>(</span><span class='nam'>co</span><span class='op'>.</span><span class='nam'>co_filename</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>filename</span> <span class='op'>==</span> <span class='nam'>_srcfile</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>f</span> <span class='op'>=</span> <span class='nam'>f</span><span class='op'>.</span><span class='nam'>f_back</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>continue</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>rv</span> <span class='op'>=</span> <span class='op'>(</span><span class='nam'>filename</span><span class='op'>,</span> <span class='nam'>f</span><span class='op'>.</span><span class='nam'>f_lineno</span><span class='op'>,</span> <span class='nam'>co</span><span class='op'>.</span><span class='nam'>co_name</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>break</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>rv</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>makeRecord</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>name</span><span class='op'>,</span> <span class='nam'>level</span><span class='op'>,</span> <span class='nam'>fn</span><span class='op'>,</span> <span class='nam'>lno</span><span class='op'>,</span> <span class='nam'>msg</span><span class='op'>,</span> <span class='nam'>args</span><span class='op'>,</span> <span class='nam'>exc_info</span><span class='op'>,</span> <span class='nam'>func</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>,</span> <span class='nam'>extra</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; A factory method which can be overridden in subclasses to create</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; specialized LogRecords.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>rv</span> <span class='op'>=</span> <span class='nam'>LogRecord</span><span class='op'>(</span><span class='nam'>name</span><span class='op'>,</span> <span class='nam'>level</span><span class='op'>,</span> <span class='nam'>fn</span><span class='op'>,</span> <span class='nam'>lno</span><span class='op'>,</span> <span class='nam'>msg</span><span class='op'>,</span> <span class='nam'>args</span><span class='op'>,</span> <span class='nam'>exc_info</span><span class='op'>,</span> <span class='nam'>func</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>extra</span> <span class='key'>is</span> <span class='key'>not</span> <span class='nam'>None</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>for</span> <span class='nam'>key</span> <span class='key'>in</span> <span class='nam'>extra</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='op'>(</span><span class='nam'>key</span> <span class='key'>in</span> <span class='op'>[</span><span class='str'>&quot;message&quot;</span><span class='op'>,</span> <span class='str'>&quot;asctime&quot;</span><span class='op'>]</span><span class='op'>)</span> <span class='key'>or</span> <span class='op'>(</span><span class='nam'>key</span> <span class='key'>in</span> <span class='nam'>rv</span><span class='op'>.</span><span class='nam'>__dict__</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>raise</span> <span class='nam'>KeyError</span><span class='op'>(</span><span class='str'>&quot;Attempt to overwrite %r in LogRecord&quot;</span> <span class='op'>%</span> <span class='nam'>key</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>rv</span><span class='op'>.</span><span class='nam'>__dict__</span><span class='op'>[</span><span class='nam'>key</span><span class='op'>]</span> <span class='op'>=</span> <span class='nam'>extra</span><span class='op'>[</span><span class='nam'>key</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>rv</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>_log</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>level</span><span class='op'>,</span> <span class='nam'>msg</span><span class='op'>,</span> <span class='nam'>args</span><span class='op'>,</span> <span class='nam'>exc_info</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>,</span> <span class='nam'>extra</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Low-level logging routine which creates a LogRecord and then calls</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; all the handlers of this logger to handle the record.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>_srcfile</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='com'>#IronPython doesn&#39;t track Python frames, so findCaller throws an</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='com'>#exception. We trap it here so that IronPython can use logging.</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>try</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>fn</span><span class='op'>,</span> <span class='nam'>lno</span><span class='op'>,</span> <span class='nam'>func</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>findCaller</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>except</span> <span class='nam'>ValueError</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>fn</span><span class='op'>,</span> <span class='nam'>lno</span><span class='op'>,</span> <span class='nam'>func</span> <span class='op'>=</span> <span class='str'>&quot;(unknown file)&quot;</span><span class='op'>,</span> <span class='num'>0</span><span class='op'>,</span> <span class='str'>&quot;(unknown function)&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>else</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>fn</span><span class='op'>,</span> <span class='nam'>lno</span><span class='op'>,</span> <span class='nam'>func</span> <span class='op'>=</span> <span class='str'>&quot;(unknown file)&quot;</span><span class='op'>,</span> <span class='num'>0</span><span class='op'>,</span> <span class='str'>&quot;(unknown function)&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>exc_info</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>type</span><span class='op'>(</span><span class='nam'>exc_info</span><span class='op'>)</span> <span class='op'>!=</span> <span class='nam'>types</span><span class='op'>.</span><span class='nam'>TupleType</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>exc_info</span> <span class='op'>=</span> <span class='nam'>sys</span><span class='op'>.</span><span class='nam'>exc_info</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>record</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>makeRecord</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>name</span><span class='op'>,</span> <span class='nam'>level</span><span class='op'>,</span> <span class='nam'>fn</span><span class='op'>,</span> <span class='nam'>lno</span><span class='op'>,</span> <span class='nam'>msg</span><span class='op'>,</span> <span class='nam'>args</span><span class='op'>,</span> <span class='nam'>exc_info</span><span class='op'>,</span> <span class='nam'>func</span><span class='op'>,</span> <span class='nam'>extra</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>handle</span><span class='op'>(</span><span class='nam'>record</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>handle</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>record</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Call the handlers for the specified record.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; This method is used for unpickled records received from a socket, as</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; well as those created locally. Logger-level filtering is applied.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='op'>(</span><span class='key'>not</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>disabled</span><span class='op'>)</span> <span class='key'>and</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>filter</span><span class='op'>(</span><span class='nam'>record</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>callHandlers</span><span class='op'>(</span><span class='nam'>record</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>addHandler</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>hdlr</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Add the specified handler to this logger.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm par run hide_run'><span class='annotate' title='no jump to this line number'>exit</span>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='key'>not</span> <span class='op'>(</span><span class='nam'>hdlr</span> <span class='key'>in</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>handlers</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>handlers</span><span class='op'>.</span><span class='nam'>append</span><span class='op'>(</span><span class='nam'>hdlr</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>removeHandler</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>hdlr</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Remove the specified handler from this logger.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>hdlr</span> <span class='key'>in</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>handlers</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='com'>#hdlr.close()</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>hdlr</span><span class='op'>.</span><span class='nam'>acquire</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>try</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>handlers</span><span class='op'>.</span><span class='nam'>remove</span><span class='op'>(</span><span class='nam'>hdlr</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>finally</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>hdlr</span><span class='op'>.</span><span class='nam'>release</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>callHandlers</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>record</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Pass a record to all relevant handlers.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Loop through all handlers for this logger and its parents in the</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; logger hierarchy. If no handler was found, output a one-off error</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; message to sys.stderr. Stop searching up the hierarchy whenever a</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; logger with the &quot;propagate&quot; attribute set to zero is found - that</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; will be the last logger whose handlers are called.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>c</span> <span class='op'>=</span> <span class='nam'>self</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>found</span> <span class='op'>=</span> <span class='num'>0</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>while</span> <span class='nam'>c</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>for</span> <span class='nam'>hdlr</span> <span class='key'>in</span> <span class='nam'>c</span><span class='op'>.</span><span class='nam'>handlers</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>found</span> <span class='op'>=</span> <span class='nam'>found</span> <span class='op'>+</span> <span class='num'>1</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>record</span><span class='op'>.</span><span class='nam'>levelno</span> <span class='op'>&gt;=</span> <span class='nam'>hdlr</span><span class='op'>.</span><span class='nam'>level</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>hdlr</span><span class='op'>.</span><span class='nam'>handle</span><span class='op'>(</span><span class='nam'>record</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='key'>not</span> <span class='nam'>c</span><span class='op'>.</span><span class='nam'>propagate</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>c</span> <span class='op'>=</span> <span class='nam'>None</span>&nbsp; &nbsp; <span class='com'>#break out</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>else</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>c</span> <span class='op'>=</span> <span class='nam'>c</span><span class='op'>.</span><span class='nam'>parent</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='op'>(</span><span class='nam'>found</span> <span class='op'>==</span> <span class='num'>0</span><span class='op'>)</span> <span class='key'>and</span> <span class='nam'>raiseExceptions</span> <span class='key'>and</span> <span class='key'>not</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>manager</span><span class='op'>.</span><span class='nam'>emittedNoHandlerWarning</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>sys</span><span class='op'>.</span><span class='nam'>stderr</span><span class='op'>.</span><span class='nam'>write</span><span class='op'>(</span><span class='str'>&quot;No handlers could be found for logger&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; <span class='str'>&quot; \&quot;%s\&quot;\n&quot;</span> <span class='op'>%</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>name</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>manager</span><span class='op'>.</span><span class='nam'>emittedNoHandlerWarning</span> <span class='op'>=</span> <span class='num'>1</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>getEffectiveLevel</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Get the effective level for this logger.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Loop through this logger and its parents in the logger hierarchy,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; looking for a non-zero logging level. Return the first one found.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>logger</span> <span class='op'>=</span> <span class='nam'>self</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>while</span> <span class='nam'>logger</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>logger</span><span class='op'>.</span><span class='nam'>level</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>logger</span><span class='op'>.</span><span class='nam'>level</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>logger</span> <span class='op'>=</span> <span class='nam'>logger</span><span class='op'>.</span><span class='nam'>parent</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>NOTSET</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>isEnabledFor</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>level</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Is this logger enabled for level &#39;level&#39;?</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>manager</span><span class='op'>.</span><span class='nam'>disable</span> <span class='op'>&gt;=</span> <span class='nam'>level</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='num'>0</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>level</span> <span class='op'>&gt;=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>getEffectiveLevel</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>class</span> <span class='nam'>RootLogger</span><span class='op'>(</span><span class='nam'>Logger</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; A root logger is not that different to any other logger, except that</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; it must have a logging level and there is only one instance of it in</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; the hierarchy.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__init__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>level</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Initialize the logger with the name &quot;root&quot;.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>Logger</span><span class='op'>.</span><span class='nam'>__init__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='str'>&quot;root&quot;</span><span class='op'>,</span> <span class='nam'>level</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='nam'>_loggerClass</span> <span class='op'>=</span> <span class='nam'>Logger</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>class</span> <span class='nam'>LoggerAdapter</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; An adapter for loggers which makes it easier to specify contextual</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; information in logging output.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__init__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>logger</span><span class='op'>,</span> <span class='nam'>extra</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Initialize the adapter with a logger and a dict-like object which</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; provides contextual information. This constructor signature allows</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; easy stacking of LoggerAdapters, if so desired.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; You can effectively pass keyword arguments as shown in the</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; following example:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; adapter = LoggerAdapter(someLogger, dict(p1=v1, p2=&quot;v2&quot;))</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>logger</span> <span class='op'>=</span> <span class='nam'>logger</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>extra</span> <span class='op'>=</span> <span class='nam'>extra</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>process</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>msg</span><span class='op'>,</span> <span class='nam'>kwargs</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Process the logging message and keyword arguments passed in to</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; a logging call to insert contextual information. You can either</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; manipulate the message itself, the keyword args or both. Return</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; the message and kwargs modified (or not) to suit your needs.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Normally, you&#39;ll only need to override this one method in a</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; LoggerAdapter subclass for your specific needs.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>kwargs</span><span class='op'>[</span><span class='str'>&quot;extra&quot;</span><span class='op'>]</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>extra</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>msg</span><span class='op'>,</span> <span class='nam'>kwargs</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>debug</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>msg</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Delegate a debug call to the underlying logger, after adding</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; contextual information from this adapter instance.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>msg</span><span class='op'>,</span> <span class='nam'>kwargs</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>process</span><span class='op'>(</span><span class='nam'>msg</span><span class='op'>,</span> <span class='nam'>kwargs</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>logger</span><span class='op'>.</span><span class='nam'>debug</span><span class='op'>(</span><span class='nam'>msg</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>info</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>msg</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Delegate an info call to the underlying logger, after adding</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; contextual information from this adapter instance.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>msg</span><span class='op'>,</span> <span class='nam'>kwargs</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>process</span><span class='op'>(</span><span class='nam'>msg</span><span class='op'>,</span> <span class='nam'>kwargs</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>logger</span><span class='op'>.</span><span class='nam'>info</span><span class='op'>(</span><span class='nam'>msg</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>warning</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>msg</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Delegate a warning call to the underlying logger, after adding</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; contextual information from this adapter instance.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>msg</span><span class='op'>,</span> <span class='nam'>kwargs</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>process</span><span class='op'>(</span><span class='nam'>msg</span><span class='op'>,</span> <span class='nam'>kwargs</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>logger</span><span class='op'>.</span><span class='nam'>warning</span><span class='op'>(</span><span class='nam'>msg</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>error</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>msg</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Delegate an error call to the underlying logger, after adding</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; contextual information from this adapter instance.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>msg</span><span class='op'>,</span> <span class='nam'>kwargs</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>process</span><span class='op'>(</span><span class='nam'>msg</span><span class='op'>,</span> <span class='nam'>kwargs</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>logger</span><span class='op'>.</span><span class='nam'>error</span><span class='op'>(</span><span class='nam'>msg</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>exception</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>msg</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Delegate an exception call to the underlying logger, after adding</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; contextual information from this adapter instance.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>msg</span><span class='op'>,</span> <span class='nam'>kwargs</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>process</span><span class='op'>(</span><span class='nam'>msg</span><span class='op'>,</span> <span class='nam'>kwargs</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>kwargs</span><span class='op'>[</span><span class='str'>&quot;exc_info&quot;</span><span class='op'>]</span> <span class='op'>=</span> <span class='num'>1</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>logger</span><span class='op'>.</span><span class='nam'>error</span><span class='op'>(</span><span class='nam'>msg</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>critical</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>msg</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Delegate a critical call to the underlying logger, after adding</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; contextual information from this adapter instance.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>msg</span><span class='op'>,</span> <span class='nam'>kwargs</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>process</span><span class='op'>(</span><span class='nam'>msg</span><span class='op'>,</span> <span class='nam'>kwargs</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>logger</span><span class='op'>.</span><span class='nam'>critical</span><span class='op'>(</span><span class='nam'>msg</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>log</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>level</span><span class='op'>,</span> <span class='nam'>msg</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Delegate a log call to the underlying logger, after adding</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; contextual information from this adapter instance.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>msg</span><span class='op'>,</span> <span class='nam'>kwargs</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>process</span><span class='op'>(</span><span class='nam'>msg</span><span class='op'>,</span> <span class='nam'>kwargs</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>logger</span><span class='op'>.</span><span class='nam'>log</span><span class='op'>(</span><span class='nam'>level</span><span class='op'>,</span> <span class='nam'>msg</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='nam'>root</span> <span class='op'>=</span> <span class='nam'>RootLogger</span><span class='op'>(</span><span class='nam'>WARNING</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='nam'>Logger</span><span class='op'>.</span><span class='nam'>root</span> <span class='op'>=</span> <span class='nam'>root</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='nam'>Logger</span><span class='op'>.</span><span class='nam'>manager</span> <span class='op'>=</span> <span class='nam'>Manager</span><span class='op'>(</span><span class='nam'>Logger</span><span class='op'>.</span><span class='nam'>root</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#---------------------------------------------------------------------------</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># Configuration classes and functions</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#---------------------------------------------------------------------------</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='nam'>BASIC_FORMAT</span> <span class='op'>=</span> <span class='str'>&quot;%(levelname)s:%(name)s:%(message)s&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>def</span> <span class='nam'>basicConfig</span><span class='op'>(</span><span class='op'>**</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Do basic configuration for the logging system.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; This function does nothing if the root logger already has handlers</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; configured. It is a convenience method intended for use by simple scripts</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; to do one-shot configuration of the logging package.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; The default behaviour is to create a StreamHandler which writes to</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; sys.stderr, set a formatter using the BASIC_FORMAT format string, and</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; add the handler to the root logger.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; A number of optional keyword arguments may be specified, which can alter</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; the default behaviour.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; filename&nbsp; Specifies that a FileHandler be created, using the specified</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; filename, rather than a StreamHandler.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; filemode&nbsp; Specifies the mode to open the file, if filename is specified</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (if filemode is unspecified, it defaults to &#39;a&#39;).</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; format&nbsp; &nbsp; Use the specified format string for the handler.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; datefmt&nbsp;&nbsp; Use the specified date/time format.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; level&nbsp; &nbsp;&nbsp; Set the root logger level to the specified level.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; stream&nbsp; &nbsp; Use the specified stream to initialize the StreamHandler. Note</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; that this argument is incompatible with &#39;filename&#39; - if both</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; are present, &#39;stream&#39; is ignored.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Note that you could specify a stream created using open(filename, mode)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; rather than passing the filename and mode in. However, it should be</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; remembered that StreamHandler does not close its stream (since it may be</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; using sys.stdout or sys.stderr), whereas FileHandler closes its stream</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; when the handler is closed.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>len</span><span class='op'>(</span><span class='nam'>root</span><span class='op'>.</span><span class='nam'>handlers</span><span class='op'>)</span> <span class='op'>==</span> <span class='num'>0</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>filename</span> <span class='op'>=</span> <span class='nam'>kwargs</span><span class='op'>.</span><span class='nam'>get</span><span class='op'>(</span><span class='str'>&quot;filename&quot;</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>filename</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>mode</span> <span class='op'>=</span> <span class='nam'>kwargs</span><span class='op'>.</span><span class='nam'>get</span><span class='op'>(</span><span class='str'>&quot;filemode&quot;</span><span class='op'>,</span> <span class='str'>&#39;a&#39;</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>hdlr</span> <span class='op'>=</span> <span class='nam'>FileHandler</span><span class='op'>(</span><span class='nam'>filename</span><span class='op'>,</span> <span class='nam'>mode</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>else</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>stream</span> <span class='op'>=</span> <span class='nam'>kwargs</span><span class='op'>.</span><span class='nam'>get</span><span class='op'>(</span><span class='str'>&quot;stream&quot;</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>hdlr</span> <span class='op'>=</span> <span class='nam'>StreamHandler</span><span class='op'>(</span><span class='nam'>stream</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>fs</span> <span class='op'>=</span> <span class='nam'>kwargs</span><span class='op'>.</span><span class='nam'>get</span><span class='op'>(</span><span class='str'>&quot;format&quot;</span><span class='op'>,</span> <span class='nam'>BASIC_FORMAT</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>dfs</span> <span class='op'>=</span> <span class='nam'>kwargs</span><span class='op'>.</span><span class='nam'>get</span><span class='op'>(</span><span class='str'>&quot;datefmt&quot;</span><span class='op'>,</span> <span class='nam'>None</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>fmt</span> <span class='op'>=</span> <span class='nam'>Formatter</span><span class='op'>(</span><span class='nam'>fs</span><span class='op'>,</span> <span class='nam'>dfs</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>hdlr</span><span class='op'>.</span><span class='nam'>setFormatter</span><span class='op'>(</span><span class='nam'>fmt</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>root</span><span class='op'>.</span><span class='nam'>addHandler</span><span class='op'>(</span><span class='nam'>hdlr</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>level</span> <span class='op'>=</span> <span class='nam'>kwargs</span><span class='op'>.</span><span class='nam'>get</span><span class='op'>(</span><span class='str'>&quot;level&quot;</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>level</span> <span class='key'>is</span> <span class='key'>not</span> <span class='nam'>None</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>root</span><span class='op'>.</span><span class='nam'>setLevel</span><span class='op'>(</span><span class='nam'>level</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#---------------------------------------------------------------------------</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># Utility functions at module level.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># Basically delegate everything to the root logger.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#---------------------------------------------------------------------------</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>def</span> <span class='nam'>getLogger</span><span class='op'>(</span><span class='nam'>name</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Return a logger with the specified name, creating it if necessary.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; If no name is specified, return the root logger.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm par run hide_run'><span class='annotate' title='no jump to this line number'>1399</span>&nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>name</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>Logger</span><span class='op'>.</span><span class='nam'>manager</span><span class='op'>.</span><span class='nam'>getLogger</span><span class='op'>(</span><span class='nam'>name</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='key'>else</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>root</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#def getRootLogger():</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#&nbsp; &nbsp; Return the root logger.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#&nbsp; &nbsp; Note that getLogger(&#39;&#39;) now does the same thing, so this function is</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#&nbsp; &nbsp; deprecated and may disappear in the future.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#&nbsp; &nbsp; return root</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>def</span> <span class='nam'>critical</span><span class='op'>(</span><span class='nam'>msg</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Log a message with severity &#39;CRITICAL&#39; on the root logger.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>len</span><span class='op'>(</span><span class='nam'>root</span><span class='op'>.</span><span class='nam'>handlers</span><span class='op'>)</span> <span class='op'>==</span> <span class='num'>0</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>basicConfig</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='nam'>root</span><span class='op'>.</span><span class='nam'>critical</span><span class='op'>(</span><span class='op'>*</span><span class='op'>(</span><span class='op'>(</span><span class='nam'>msg</span><span class='op'>,</span><span class='op'>)</span><span class='op'>+</span><span class='nam'>args</span><span class='op'>)</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='nam'>fatal</span> <span class='op'>=</span> <span class='nam'>critical</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>def</span> <span class='nam'>error</span><span class='op'>(</span><span class='nam'>msg</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Log a message with severity &#39;ERROR&#39; on the root logger.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>len</span><span class='op'>(</span><span class='nam'>root</span><span class='op'>.</span><span class='nam'>handlers</span><span class='op'>)</span> <span class='op'>==</span> <span class='num'>0</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>basicConfig</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='nam'>root</span><span class='op'>.</span><span class='nam'>error</span><span class='op'>(</span><span class='op'>*</span><span class='op'>(</span><span class='op'>(</span><span class='nam'>msg</span><span class='op'>,</span><span class='op'>)</span><span class='op'>+</span><span class='nam'>args</span><span class='op'>)</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>def</span> <span class='nam'>exception</span><span class='op'>(</span><span class='nam'>msg</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Log a message with severity &#39;ERROR&#39; on the root logger,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; with exception information.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='nam'>error</span><span class='op'>(</span><span class='op'>*</span><span class='op'>(</span><span class='op'>(</span><span class='nam'>msg</span><span class='op'>,</span><span class='op'>)</span><span class='op'>+</span><span class='nam'>args</span><span class='op'>)</span><span class='op'>,</span> <span class='op'>**</span><span class='op'>{</span><span class='str'>&#39;exc_info&#39;</span><span class='op'>:</span> <span class='num'>1</span><span class='op'>}</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>def</span> <span class='nam'>warning</span><span class='op'>(</span><span class='nam'>msg</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Log a message with severity &#39;WARNING&#39; on the root logger.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>len</span><span class='op'>(</span><span class='nam'>root</span><span class='op'>.</span><span class='nam'>handlers</span><span class='op'>)</span> <span class='op'>==</span> <span class='num'>0</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>basicConfig</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='nam'>root</span><span class='op'>.</span><span class='nam'>warning</span><span class='op'>(</span><span class='op'>*</span><span class='op'>(</span><span class='op'>(</span><span class='nam'>msg</span><span class='op'>,</span><span class='op'>)</span><span class='op'>+</span><span class='nam'>args</span><span class='op'>)</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='nam'>warn</span> <span class='op'>=</span> <span class='nam'>warning</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>def</span> <span class='nam'>info</span><span class='op'>(</span><span class='nam'>msg</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Log a message with severity &#39;INFO&#39; on the root logger.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>len</span><span class='op'>(</span><span class='nam'>root</span><span class='op'>.</span><span class='nam'>handlers</span><span class='op'>)</span> <span class='op'>==</span> <span class='num'>0</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>basicConfig</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='nam'>root</span><span class='op'>.</span><span class='nam'>info</span><span class='op'>(</span><span class='op'>*</span><span class='op'>(</span><span class='op'>(</span><span class='nam'>msg</span><span class='op'>,</span><span class='op'>)</span><span class='op'>+</span><span class='nam'>args</span><span class='op'>)</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>def</span> <span class='nam'>debug</span><span class='op'>(</span><span class='nam'>msg</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Log a message with severity &#39;DEBUG&#39; on the root logger.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>len</span><span class='op'>(</span><span class='nam'>root</span><span class='op'>.</span><span class='nam'>handlers</span><span class='op'>)</span> <span class='op'>==</span> <span class='num'>0</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>basicConfig</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='nam'>root</span><span class='op'>.</span><span class='nam'>debug</span><span class='op'>(</span><span class='op'>*</span><span class='op'>(</span><span class='op'>(</span><span class='nam'>msg</span><span class='op'>,</span><span class='op'>)</span><span class='op'>+</span><span class='nam'>args</span><span class='op'>)</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>def</span> <span class='nam'>log</span><span class='op'>(</span><span class='nam'>level</span><span class='op'>,</span> <span class='nam'>msg</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Log &#39;msg % args&#39; with the integer severity &#39;level&#39; on the root logger.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>len</span><span class='op'>(</span><span class='nam'>root</span><span class='op'>.</span><span class='nam'>handlers</span><span class='op'>)</span> <span class='op'>==</span> <span class='num'>0</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>basicConfig</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='nam'>root</span><span class='op'>.</span><span class='nam'>log</span><span class='op'>(</span><span class='op'>*</span><span class='op'>(</span><span class='op'>(</span><span class='nam'>level</span><span class='op'>,</span> <span class='nam'>msg</span><span class='op'>)</span><span class='op'>+</span><span class='nam'>args</span><span class='op'>)</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>def</span> <span class='nam'>disable</span><span class='op'>(</span><span class='nam'>level</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Disable all logging calls less severe than &#39;level&#39;.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='nam'>root</span><span class='op'>.</span><span class='nam'>manager</span><span class='op'>.</span><span class='nam'>disable</span> <span class='op'>=</span> <span class='nam'>level</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>def</span> <span class='nam'>shutdown</span><span class='op'>(</span><span class='nam'>handlerList</span><span class='op'>=</span><span class='nam'>_handlerList</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Perform any cleanup actions in the logging system (e.g. flushing</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; buffers).</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Should be called at application exit.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>for</span> <span class='nam'>h</span> <span class='key'>in</span> <span class='nam'>handlerList</span><span class='op'>[</span><span class='op'>:</span><span class='op'>]</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='com'>#errors might occur, for example, if files are locked</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='com'>#we just ignore them if raiseExceptions is not set</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>try</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>h</span><span class='op'>.</span><span class='nam'>flush</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>h</span><span class='op'>.</span><span class='nam'>close</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>except</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>raiseExceptions</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>raise</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='com'>#else, swallow</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#Let&#39;s try and shutdown automatically on application exit...</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>try</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>import</span> <span class='nam'>atexit</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='nam'>atexit</span><span class='op'>.</span><span class='nam'>register</span><span class='op'>(</span><span class='nam'>shutdown</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='key'>except</span> <span class='nam'>ImportError</span><span class='op'>:</span> <span class='com'># for Python versions &lt; 2.0</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>exithook</span><span class='op'>(</span><span class='nam'>status</span><span class='op'>,</span> <span class='nam'>old_exit</span><span class='op'>=</span><span class='nam'>sys</span><span class='op'>.</span><span class='nam'>exit</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>try</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>shutdown</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>finally</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>old_exit</span><span class='op'>(</span><span class='nam'>status</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='nam'>sys</span><span class='op'>.</span><span class='nam'>exit</span> <span class='op'>=</span> <span class='nam'>exithook</span><span class='strut'>&nbsp;</span></p>
    
</td>
</tr>
</table>
</div>

</body>
</html>
